I'm trying to use Gaufrette with Aws SDK2, and I'm getting the following error on a cache:clear after configuring:
[Aws\Common\Exception\InvalidArgumentException]
The provided signature value is not an instance of S3SignatureInterface
Here is my setup.
composer.json
"aws/aws-sdk-php": "2.6.*#dev"
config.yml
services:
src.aws_s3.client:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: 'factory'
arguments:
key: %amazon_aws_key%
secret: %amazon_aws_secret_key%
region: US Standard
...
knp_gaufrette:
adapters:
media_adapter:
aws_s3:
service_id: 'src.aws_s3.client'
bucket_name: my.bucket
options:
directory: 'media'
GitHub: https://github.com/KnpLabs/KnpGaufretteBundle/issues/90
The problem was a mistake in the arguments of the service declaration (which I should've seen). It needs to be a collection like so:
config.yml
services:
src.aws_s3.client:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: 'factory'
arguments:
- key: %amazon_aws_key%
secret: %amazon_aws_secret_key%
Related
I have a Sulu and a Sylius application which I am trying to integrate using the SuluSyliusBundle and RabbitMQ. I have added the following configs...
messenger.yaml
framework:
router:
resource: "%kernel.project_dir%/config/routing_%sulu.context%.yml"
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
buses:
message_bus:
middleware:
- doctrine_transaction
- event_middleware
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed
transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
# sync: 'sync://'
routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async
sulu_sylius_consumer.yaml
sylius_base_url: 'http://127.0.0.1:8001'
sylius_default_channel: 'default_channel'
sylius_oauth_config:
username: api
password: api
client_id: demo_client
client_secret: secret_demo_client
route_defaults_fallback:
view: 'templates/products/default'
firewall_provider_key: 'main'
The issue is that once I install the bundle and add these two configs, I get the following error
I believe this is being caused by the config in the messenger. I have added the routes to routes_admin.yaml as it is show in the documentation here:
routes_admin.yaml
app_events:
type: rest
resource: App\Controller\Admin\EventController
prefix: /admin/api
name_prefix: app.
options:
expose: true
app_event_registrations:
type: rest
resource: App\Controller\Admin\EventRegistrationController
prefix: /admin/api
name_prefix: app.
options:
expose: true
app_locations:
type: rest
resource: App\Controller\Admin\LocationController
prefix: /admin/api
name_prefix: app.
options:
expose: true
app_products:
type: rest
resource: App\Controller\Admin\ProductsController
prefix: /admin/api
name_prefix: app.
options:
expose: true
sulu_route:
mappings:
Sulu\Bundle\SyliusConsumerBundle\Model\RoutableResource\RoutableResource:
generator: schema
resource_key: product_content
options:
route_schema: "/products/{object.getCode()}"
routes_website.yaml
app.event:
path: /{_locale}/event/{id}
controller: App\Controller\Website\EventWebsiteController::indexAction
app.product:
path: /{_locale}/product/{id}
controller: App\Controller\Website\ProductWebsiteController::indexAction
What can I do to fix this error?
[edit: added routes_admin and routes_website yaml]
It throws this error:
Unrecognized option "handler" under "fos_user.registration.form"
And the files are:
//services.yml
app.form.registration:
class: AppBundle\Form\AccomodationFrontSignUpType
tags:
- { name: form.type, alias: app_user_registration }
app.form.handler.registration:
class: AppBundle\Form\Handler\RegistrationFormHandler
arguments: ["#fos_user.registration.form", "#request", "#fos_user.user_manager", "#fos_user.mailer", "#fos_user.util.token_generator"]
scope: request
public: false
//config.yml
fos_user:
db_driver: orm
firewall_name: main
user_class: AppBundle\Entity\User
group:
group_class: AppBundle\Entity\Group
service:
mailer: swiftmailer.mailer.strato
from_email:
address: webmyhomepage#strato.com
sender_name: myHomepage
registration:
form:
handler: app.form.handler.registration
type: app_user_registration
confirmation:
template: FOSUserBundle:Registration:email.txt.twig
enabled: true
Any help is welcome, thanks
The error means that there is an invalid parameter in your config. The key handler in your config
-> handler: app.form.handler.registration
if you take a look inside the fos user bundle DependencyInjection folder, Configuration.php file, that option does not exist. so its invalid :).
There you can see witch options are available. In my current version of this bundle i have this options available under form: type, name, validation_groups.
Also you can see the default configuration for a bundle with:
php app/console debug:config FOSUserBundle
I want to set Amazon S3 settings from database and not from parameters.yml
can someone point me to right direction on how to use database (doctrine) parameters before symfony2 calls services.
#app/config/config.yml
services:
acme.aws_s3.client:
class: Aws\S3\S3Client
factory_class: Aws\S3\S3Client
factory_method: 'factory'
arguments:
-
key: %amazon_s3.key%
secret: %amazon_s3.secret%
# knp_gaufrette
knp_gaufrette:
adapters:
profile_photos:
aws_s3:
service_id: 'acme.aws_s3.client'
bucket_name: 'myBucket'
options:
directory: 'myDirectory'
acl: 'public-read'
Use your own service factory for acme.aws_s3.client service configuration.
services:
acme.aws_s3.client:
class: Aws\S3\S3Client
factory_class: My\S3ClientFactory
factory_method: createClient
arguments: [ #settings_repository ]
#settings_repository - any service that has access to db. E.g. doctrine entity repositry, or entire object manager.
My\S3ClientFactory::createClient - pretty much the same as native Aws\S3\S3Client::factory except that it would take params from db.
Hope this helpful.
So I have my KnpGaufretteBundle configured like this:
knp_gaufrette:
adapters:
local_shared:
local:
directory: "%shared.dir%"
create: false
filesystems:
local_shared:
adapter: local_shared
alias: defaul_fs
Then I need to inject it to my own service, I do this:
acme.user_manager:
class: %acme_user.user_manager.class%
arguments: [#doctrine.orm.entity_manager, #security.context]
calls:
- [setFilesystem, [#default_fs]]
But this breaks with exception The service definition "default_fs" does not exist.
If I use #gaufrette.local_shared_filesystem as a parameter instead of #default_fs then it works like expected. But I would like to use an alias.
Please help.
I'm assuming that you noticed that you have a typo in your config declaration:
alias: defaul_fs
has no "t"
Here are params.
app/config/parameters.yml
parameters:
test:
enabled: true
validate: true
And this is service which I want to configure with test param from previous file.
MyBundle/Resources/config/services.yml
imports:
- { resource: "parameters.yml" }
parameters:
services:
my.form.type:
class: My\Bundle\Form\Type\MyType
arguments:
- %test%
Import doesn't work this way. How should I do it?
PS I know I can refer to #service_container. But the point is to pass array explicitly via yaml.
you can ommit ...
imports:
- { resource: "parameters.yml" }
parameters:
... parameters.yml should automatically be parsed and the parameters should be available for injection if you surround them with %.
Try:
services:
my.form.type:
class: My\Bundle\Form\Type\MyType
arguments: ["%test%"]
alias: my_form_type