aws / aws-sdk-php-symfony

Apache License 2.0
350 stars 87 forks source link

Missing required client configuration options #10

Closed bmeynell closed 8 years ago

bmeynell commented 8 years ago

I get this error after attempting to install (Symfony version 2.7.7):

  [InvalidArgumentException]                                                          
  Missing required client configuration options:                                      
  version: (string)                                                                   
    A "version" configuration value is required. Specifying a version constraint      
    ensures that your code will not be affected by a breaking change made to the      
    service. For example, when using Amazon S3, you can lock your API version to      
    "2006-03-01".                                                                     

    Your build of the SDK has the following version(s) of "s3": * "2006-03-01"        

    You may provide "latest" to the "version" configuration value to utilize the      
    most recent available API version that your client's API provider can find.       
    Note: Using 'latest' in a production application is not recommended.              

    A list of available API versions can be found on each client's API documentation  
    page: http://docs.aws.amazon.com/aws-sdk-php/v3/api/index.html. If you are        
    unable to load a specific API version, then you may need to update your copy of   
    the SDK.   
$ php -v
PHP 5.5.9-1ubuntu4.13 (cli) (built: Sep 29 2015 15:24:49) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
mtdowling commented 8 years ago

You need to provide a "version" when creating an SDK client. You can pass "latest" if you don't care which version you use, but it still must be explicitly set.

bmeynell commented 8 years ago

You need to provide a "version" when creating an SDK client. You can pass "latest" if you don't care which version you use, but it still must be explicitly set.

Is there an example of this somewhere? Where is the SDK client currently constructed? How does it tie into composer? All that was done is add this library to composer.

jeskew commented 8 years ago

I am unable to reproduce on a fresh install of Symfony 2.7.7.

This bundle declares services with names like aws.s3 and aws.ec2. Nothing should be constructed unless you've added an instance of \Aws\Symfony\AwsBundle to your application's kernel and you're injecting an aws.<service> service somewhere. If that's the case, then you'll need to provide a few configuration parameters, including a region and a version. This package's tests/fixtures directory contains an example configuration.

mtdowling commented 8 years ago

Sure: http://docs.aws.amazon.com/aws-sdk-php/v3/guide/getting-started/basic-usage.html#creating-a-client. More information: http://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/configuration.html#version.

How does it tie into composer? All that was done is add this library to composer.

What's in your dependency graph? At what point does this failure occur? It could be that you have some Composer plugin that has a loose version constraint that is suddenly being updated from v2 to v3.

composer.phar show --installed
bmeynell commented 8 years ago

Thanks for assisting with this, guys.

At what point does this failure occur?

By simply running php app/console:

$ php app/console                                                                  

  [InvalidArgumentException]                                                              
  Missing required client configuration options:                                          
  version: (string)                                                                       
    A "version" configuration value is required. Specifying a version constraint          
    ensures that your code will not be affected by a breaking change made to the          
    service. For example, when using Amazon S3, you can lock your API version to          
    "2006-03-01".                                                                         

    Your build of the SDK has the following version(s) of "s3": * "2006-03-01"            

    You may provide "latest" to the "version" configuration value to utilize the    
    most recent available API version that your client's API provider can find.           
    Note: Using 'latest' in a production application is not recommended.                  

    A list of available API versions can be found on each client's API documentation  
    page: http://docs.aws.amazon.com/aws-sdk-php/v3/api/index.html. If you are            
    unable to load a specific API version, then you may need to update your copy of   
    the SDK.                                                                              

Exception trace:                                                                   
 () at /var/www/project/current/vendor/aws/aws-sdk-php/src/ClientResolver.php:328
 Aws\ClientResolver->throwRequired() at /var/www/project/current/vendor/aws/aws-sdk-php/src/ClientResolver.php:224
 Aws\ClientResolver->resolve() at /var/www/project/current/vendor/aws/aws-sdk-php/src/AwsClient.php:137
 Aws\AwsClient->__construct() at /var/www/project/current/vendor/aws/aws-sdk-php/src/S3/S3Client.php:178
 Aws\S3\S3Client->__construct() at /var/www/project/current/vendor/aws/aws-sdk-php/src/AwsClient.php:349
 Aws\AwsClient::factory() at /var/www/project/current/app/cache/dev/appDevDebugProjectContainer.php:4386
 appDevDebugProjectContainer->getMedia_AwsS3_ClientService() at /var/www/project/current/app/bootstrap.php.cache:2155
 Symfony\Component\DependencyInjection\Container->get() at /var/www/project/current/app/cache/dev/appDevDebugProjectContainer.php:2952
 appDevDebugProjectContainer->getGaufrette_PhotosFilesystemService() at /var/www/project/current/app/bootstrap.php.cache:2155
 Symfony\Component\DependencyInjection\Container->get() at /var/www/project/current/app/cache/dev/appDevDebugProjectContainer.php:3620
 appDevDebugProjectContainer->getKnpGaufrette_FilesystemMapService() at /var/www/project/current/app/bootstrap.php.cache:2155
 Symfony\Component\DependencyInjection\Container->get() at /var/www/project/current/vendor/knplabs/knp-gaufrette-bundle/Knp/Bundle/GaufretteBundle/KnpGaufretteBundle.php:41
 Knp\Bundle\GaufretteBundle\KnpGaufretteBundle->boot() at /var/www/project/current/app/bootstrap.php.cache:2414
 Symfony\Component\HttpKernel\Kernel->boot() at /var/www/project/current/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:70
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /var/www/project/current/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:120
 Symfony\Component\Console\Application->run() at /var/www/project/current/app/console:23

What's in your dependency graph?

$ composer show --installed

alchemy/binary-driver               1.4.1                            A set of tools to build binary drivers
antimattr/mongodb-migrations        v1.0.0                           Managed Database Migrations for MongoDB
antimattr/mongodb-migrations-bundle v1.0.1                           Symfony MongoDBMigrationsBundle
aws/aws-sdk-php                     3.11.5                           AWS SDK for PHP - Use Amazon Web Services in your PHP project
aws/aws-sdk-php-symfony             1.0.2                            A Symfony bundle for v3 of the AWS SDK for PHP
behat/transliterator                v1.1.0                           String transliterator
bmeynell/phpbb3                     dev-Multi_Domain_Support 3741e2f PhpBB3 used with the WidopPhpBBBundle.
bmeynell/slideshare-bundle          dev-master 1ffe17f               Symfony SlideShare Bundle
bmeynell/WordPress                  master master                               
bmeynell/zendservice-slideshare     dev-master 12b4351               OOP wrapper for the SlideShare web service
braincrafted/bootstrap-bundle       v2.1.2                           BraincraftedBootstrapBundle integrates Bootstrap into Symfony2 by providing templates, Twig extensions, services and commands.
container-interop/container-interop 1.1.0                            Promoting the interoperability of container objects (DIC, SL, etc.)
dailymotion/sdk                     dev-master 0f55897               Dailymotion PHP SDK
datumbox/datumbox-api-client-php    master master                               
desarrolla2/cache                   1.8.1                            Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported. New ada...
desarrolla2/rss-client              v2.2.1                           A simple to use RSS client library.
desarrolla2/rss-client-bundle       v2.0.4                           This Bundle provides a way to get rss feeds friendly.
doctrine/annotations                v1.2.7                           Docblock Annotations Parser
doctrine/cache                      v1.5.2                           Caching library offering an object-oriented API for many cache backends
doctrine/collections                v1.3.0                           Collections Abstraction library
doctrine/common                     v2.6.0                           Common Library for Doctrine projects
doctrine/dbal                       v2.4.4                           Database Abstraction Layer
doctrine/doctrine-bundle            v1.2.0                           Symfony DoctrineBundle
doctrine/doctrine-cache-bundle      1.0.0                            Symfony2 Bundle for Doctrine Cache
doctrine/doctrine-migrations-bundle dev-master 86d2b1c               Symfony DoctrineMigrationsBundle
doctrine/inflector                  v1.0.1                           Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator               1.0.5                            A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                      v1.0.1                           Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/migrations                 dev-master b386d2a               Database Schema migrations using Doctrine DBAL
doctrine/mongodb                    1.2.1                            Doctrine MongoDB Abstraction Layer
doctrine/mongodb-odm                1.0.3                            Doctrine MongoDB Object Document Mapper
doctrine/mongodb-odm-bundle         dev-master 5a6b2bc               Symfony2 Doctrine MongoDB Bundle
doctrine/orm                        v2.4.8                           Object-Relational-Mapper for PHP
embedly/embedly-php                 dev-master a2cbf6d               Embedly library for PHP
endroid/twitter                     1.1.6                            Endroid Twitter
endroid/twitter-bundle              dev-master 99b700f               Endroid Twitter Bundle for Symfony
evenement/evenement                 v1.0.0                           Événement is a very simple event dispatching library for PHP 5.3
ezyang/htmlpurifier                 v4.5.0                           Standards compliant HTML filter written in PHP
fabpot/goutte                       dev-master 3cbc6ed               A simple PHP Web Scraper
friendsofsymfony/http-cache         1.4.0                            Tools to manage cache invalidation
friendsofsymfony/http-cache-bundle  dev-master 3d318fb               Set path based HTTP cache headers and send invalidation requests to your HTTP cache
friendsofsymfony/jsrouting-bundle   1.5.4                            A pretty nice way to expose your Symfony2 routing to client applications.
friendsofsymfony/rest               0.8.0                            This library provides various tools to develop RESTful API's
friendsofsymfony/rest-bundle        0.13.1                           This Bundle provides various tools to rapidly develop RESTful API's with Symfony2
gedmo/doctrine-extensions           v2.4.9                           Doctrine2 behavioral extensions
guzzle/guzzle                       v3.9.2                           Guzzle is a PHP HTTP client library and framework for building RESTful web service clients
guzzlehttp/guzzle                   6.1.1                            Guzzle is a PHP HTTP client library
guzzlehttp/promises                 1.0.3                            Guzzle promises library
guzzlehttp/psr7                     1.2.1                            PSR-7 message implementation
h2s/reddit-api-client               dev-master a12df2b               Provides an interface to the API at reddit.com
hamcrest/hamcrest-php               v1.2.2                           This is the PHP port of Hamcrest Matchers
hwi/oauth-bundle                    dev-master 86b5a87               Support for authenticating users using both OAuth1.0a and OAuth2 in Symfony2.
imagine/imagine                     0.5.x-dev 343580f                Image processing for PHP 5.3
jdorn/sql-formatter                 v1.2.17                          a PHP SQL highlighting library
jms/aop-bundle                      1.2.0                            Adds AOP capabilities to Symfony2
jms/cg                              1.1.0                            Toolset for generating PHP code
jms/di-extra-bundle                 dev-master e2181b8               Allows to configure dependency injection using annotations
jms/metadata                        1.5.1                            Class/method/property metadata management in PHP
jms/parser-lib                      1.0.0                            A library for easily creating recursive-descent parsers.
jms/security-extra-bundle           dev-master 75bd0f7               Enhances the Symfony2 Security Component by adding several new features
jms/serializer                      0.12.0                           Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.
jms/serializer-bundle               0.12.0                           Allows you to easily serialize, and deserialize data of any complexity
jquery/jquery                       1.11.1                                      
jwage/easy-csv                      dev-master 223dbbe               Easy CSV manipulation for PHP 5.4+
knplabs/gaufrette                   dev-master 434dddb               PHP5 library that provides a filesystem abstraction layer
knplabs/knp-components              dev-master 07d445c               Knplabs component library
knplabs/knp-gaufrette-bundle        dev-master d1eb6f2               Allows to easily use the Gaufrette library in a Symfony project
knplabs/knp-menu                    v2.0.1                           An object oriented menu library
knplabs/knp-menu-bundle             v2.0.0                           This bundle provides an integration of the KnpMenu library
knplabs/knp-paginator-bundle        dev-master 5147740               Paginator bundle for Symfony2 to automate pagination and simplify sorting and other features
knplabs/knp-time-bundle             dev-master cb9b76a               Knplabs time bundle makes your dates look sensible and descriptive
kriswallsmith/assetic               v1.2.1                           Asset Management for PHP
kriswallsmith/buzz                  v0.15                            Lightweight HTTP client
liip/imagine-bundle                 dev-master 471a261               This Bundle assists in imagine manipulation using the imagine library
misd/guzzle-bundle                  v1.1.5                           Integrates Guzzle into your Symfony2 application
mmoreram/gearman-bundle             v2.4.2                           Adds gearman support to your Symfony2 project
mockery/mockery                     dev-master 9c29a2f               Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework...
monolog/monolog                     1.17.2                           Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/jmespath.php              2.2.0                            Declaratively specify how to extract elements from a JSON document
nelmio/solarium-bundle              v2.2.0                           Integration with solarium solr client.
nikkobautista/scribd                dev-master d883ba8               Composer-compatible Scribd PHP library (based on Robert Pottorff's version
ob/highcharts-bundle                dev-master e11ce26               Symfony2 Bundle that ease the use of highcharts to display rich graph and charts in your app
phpcollection/phpcollection         0.2.0                            General-Purpose Collection Library for PHP
phpoption/phpoption                 1.5.0                            Option Type for PHP
phpunit/php-code-coverage           1.2.18                           Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator           1.4.1                            FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template           1.2.1                            Simple template engine.
phpunit/php-timer                   1.0.7                            Utility class for timing
phpunit/php-token-stream            1.2.2                            Wrapper around PHP's tokenizer extension.
phpunit/phpunit                     3.7.x-dev 38709dc                The PHP Unit Testing framework.
phpunit/phpunit-mock-objects        1.2.3                            Mock Object library for PHPUnit
predis/predis                       v0.8.7                           Flexible and feature-complete PHP client library for Redis
psr/http-message                    1.0                              Common interface for HTTP messages
psr/log                             1.0.0                            Common interface for logging libraries
sensio/distribution-bundle          v2.3.22                          The base bundle for the Symfony Distributions
sensio/framework-extra-bundle       v2.3.4                           This bundle provides a way to configure your controllers with annotations
sensio/generator-bundle             v2.3.5                           This bundle generates code for you
snc/redis-bundle                    dev-master 38b8673               A Redis bundle for Symfony2
solarium/solarium                   3.4.1                            PHP Solr client
stof/doctrine-extensions-bundle     dev-master 6672ca3               Integration of the gedmo/doctrine-extensions with Symfony2
swiftmailer/swiftmailer             v5.4.1                           Swiftmailer, free feature-rich PHP mailer
symfony/assetic-bundle              v2.4.0                           Integrates Assetic into Symfony2
symfony/expression-language         2.6.x-dev f4cffea                Symfony ExpressionLanguage Component
symfony/monolog-bundle              v2.3.0                           Symfony MonologBundle
symfony/swiftmailer-bundle          v2.3.9                           Symfony SwiftmailerBundle
symfony/symfony                     v2.7.7                           The Symfony PHP framework
thomaspark/bootswatch               v3.2.0+4                         Themes for Bootstrap
twbs/bootstrap                      v3.0.0                           Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
twig/extensions                     v1.0.1                           Common additional features for Twig that do not directly belong in core
twig/twig                           v1.23.1                          Twig, the flexible, fast, and secure template language for PHP
vimeo/sdk                           master master                               
webgriffe/pdftotext-bundle          dev-master 65ee6af               This bundle integrates Symfony2 with pdftotext binary command.
widop/phpbb-bundle                  master master                               
willdurand/jsonp-callback-validator v1.1.0                           JSONP callback validator.
willdurand/negotiation              1.0.5                            Content Negotiation tools for PHP provided as a standalone library.
zendframework/zend-cache            2.5.3                            provides a generic way to cache any data
zendframework/zend-escaper          2.5.1                                       
zendframework/zend-eventmanager     2.6.1                                       
zendframework/zend-http             2.5.3                            provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests
zendframework/zend-hydrator         1.0.0                                       
zendframework/zend-json             2.6.0                            provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP
zendframework/zend-loader           2.5.1                                       
zendframework/zend-math             2.5.1                                       
zendframework/zend-serializer       2.5.1                            provides an adapter based interface to simply generate storable representation of PHP types by different facilities, and recover
zendframework/zend-servicemanager   2.6.0                                       
zendframework/zend-stdlib           2.7.4                                       
zendframework/zend-uri              2.5.1                            a component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)
zendframework/zend-validator        2.5.3                            provides a set of commonly needed validators
zendframework/zend-version          2.5.1                                       

I also tried instantiating this bundle in app/AppKernel.php and added default configuration in app/config.yml as per @jeskew's suggestions here --> https://github.com/aws/aws-sdk-php-symfony/issues/10#issuecomment-163380374 but still encountered the failure described above.

jeskew commented 8 years ago

It looks like the error is actually coming from Gaufrette, which is trying to instantiate an S3 Client in appDevDebugProjectContainer->getMedia_AwsS3_ClientService().

From Gaufrette's documentation, it does not appear that they support v3 of the SDK, just v1 and v2. Did you have v2 installed before?

jeskew commented 8 years ago

Actually, you might want to try passing a version argument where you're declaring an S3 service for Gaufrette. I haven't tested that package, but it appears that they support passing arbitrary arguments to the S3 client constructor.

bmeynell commented 8 years ago

I forked Gaufrette a long time ago in order to auto-detect content type. I'll dig deeper into Gaufrette and report back what I find here. It's probably the culprit.

bmeynell commented 8 years ago

Update: Fixed.

Previous to this aws-sdk-php-symfony library I was manually creating AWS services and injecting them into Gaufrette and/or LiipImagine. For example, so create an s3 service I had:

services:
    aws.s3.client:
        class: Aws\S3\S3Client
        factory_class: Aws\S3\S3Client
        factory_method: 'factory'
        arguments:
            - 
                key:    %aws.key%
                secret: %aws.secret%
                region: %aws.region%

Now, after suggestions from @mtdowling and @jeskew (thanks guys!!!), ALL AWS services are automatically available within my application:

$ php app/console container:debug |grep aws |head
 aws.apigateway                                             Aws\ApiGateway\ApiGatewayClient                                                                       
 aws.autoscaling                                            Aws\AutoScaling\AutoScalingClient                                                                     
 aws.cloudformation                                         Aws\CloudFormation\CloudFormationClient                                                               
 aws.cloudfront                                             Aws\CloudFront\CloudFrontClient                                                                       
 aws.cloudhsm                                               Aws\CloudHsm\CloudHsmClient                                                                           
 aws.cloudsearch                                            Aws\CloudSearch\CloudSearchClient                                                                     
 aws.cloudsearchdomain                                      Aws\CloudSearchDomain\CloudSearchDomainClient                                                         
 aws.cloudtrail                                             Aws\CloudTrail\CloudTrailClient                                                                       
 aws.cloudwatch                                             Aws\CloudWatch\CloudWatchClient                                                                       
 aws.cloudwatchlogs                                         Aws\CloudWatchLogs\CloudWatchLogsClient 
... rest of output intentionally truncated ...

All I had to do was add this to my app/config/config.yml:

aws:
    version: latest
    region: %aws.region%
    credentials:
        key: %aws.key%
        secret: %aws.secret%

So, thanks again guys. Great addition to the Symfony community and looking forward to using a lot of these AWS services with the latest SDK!