By using AWS re:Post, you agree to the AWS re:Post Terms of Use

Using AWS PHP SDK on Elastic Beanstalk

0

So I have a PHP web app on Elastic Beanstalk, and I'm trying to use the PHP AWS SDK to work with files on S3. So far I haven't got it working.
Per this documentation: https://docs.aws.amazon.com/aws-sdk-php/v2/guide/installation.html#using-composer-with-aws-elastic-beanstalk
I have the following in a composer.json file at the root level of my application:
{
"require": {
"aws/aws-sdk-php": "3.*"
}
}
Do I need something else in it? Like an autoload section or something?

Since the aws.phar file is over 16MB, I don't want to include it in my app and have to upload it every time I make an unrelated update; from what I understand, Elastic Beanstalk already has Composer installed, and the above json should install the AWS PHP SDK on deployment.

I'm thinking I need a require('/vendor/autoload.php'); or something in my code? If so, how do I know where the autoload.php file is on Elastic Beanstalk? Or do I need to create one? (And if so, what do I put in it?) When I used that line, I just get an error saying it can't find the file.

I don't have a vendor folder in my application.

asked 5 years ago622 views
1 Answer
0

For future reference, I figured this out as follows.
I had been getting "No composer.json file detected" in my logs.

I discovered that because of the way I was zipping my package on macOS (using the native right click > Compress), it puts the files in a sub-folder inside the zipped package. So the composer.json was not at the "root" level of my package. I added it to the "root" level, and then once deployed I got the following in the logs:
Found composer.json file. Attempting to install vendors. (...)

And then the path to "vendor/autoload.php" was not in the directory with my application either (NOT /var/app/current/application-files/web/vendor), but closer to the root level (e.g. /var/app/current/vendor)

Hopefully this saves someone else some headaches!

answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions