Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Issues with Loading AWS SDK via Composer
  • Trying to load the Amazon Web Services SDK via composer.  They statethat it is PSR-0 compliant.  I have composer setup and installed the sdk package under APPPATH.'vendor'

    Have tried lots of variants, including a require to include the composer autoload.php file, no luck with recognizing the "Aws" namespace.  I have tried adding the namespace via these two ways:

    Autoloader::add_namespace('Aws',APPPATH.'vendor/aws/aws-sdk-php/src/Aws',true);
    Autoloader::add_namespace('Aws',APPPATH.'vendor/aws',true);

    I tried the second one after reading another post regarding general composer package usage that seemed to recommend just setting the top-level package folder.

    In first use case I am trying to use the S3 storage library inside of one of my models.  I have the following at the top as recomended by the AWS example documentation:

    use \Aws\Common\Aws;
    use \Aws\S3\Enum\CannedAcl;
    use \Aws\S3\Exception\S3Exception;

    Still getting an error that class Aws is not found.

    Any ideas or recommendations on including this composer package?

    I looked over this post: http://fuelphp.com/forums/discussion/comment/11674#Comment_11674

    And the referenced post here: http://tomschlick.com/2012/11/01/composer-with-fuelphp/

    But no luck
  • Some more testing and variations and got things to work, not sure what final tweaks were but this is what my setup is like that has it working now:

    I did the same as instructions: http://tomschlick.com/2012/11/01/composer-with-fuelphp/

    With difference being I have my composer packages loaded under fuel/app/vendor/<composer packages>

    ****Like Tom points out, make sure you require the composer autoload.php file after you register your namespaces in app/bootstrap.php:

          require APPPATH.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';

    I added the AWS namespace under my app/bootstrap.php file:

              Autoloader::add_namespace('Aws',APPPATH.'vendor/aws/aws-sdk-php/src/Aws',true);

    In my model (or any file where you want to include the AWS S3 libs):

           use Aws\Common\Aws;
           use Aws\S3\Enum\CannedAcl;
           use Aws\S3\Exception\S3Exception;


    And instantiated like so in my model:

          $_s3 = Aws::factory($s3_cfg)->get('s3');

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion