Apparently I’m missing something when trying to deploy my application in EB. I’m getting this error:
Instance deployment: You didn't include a 'composer.json' file in your source bundle. The deployment didn't install Composer dependencies.
I’m following the docs here and here. Here’s a view of the file structure:
.
|____Buildfile
|____composer.json
|____composer.lock
|____index.php
|____api
| |____v1
| | |____index.php
My Buildfile:
01_composer_install: composer install
Any help or guidance would be much appreciated.
UPDATE:
I tried adding the .platform hooks with no success. Same error.
New tree structure:
.
|____.platform
| |____hooks
| | |____predeploy
| | | |____01_composer_install.sh
|____composer.json
|____composer.lock
|____index.php
|____api
| |____v1
| | |____index.php
01_composer_install.sh
contents:
#!/bin/bash
composer install
2
Answers
Most likely your zip file (assuming you uploaded as zip) has a directory on top. That is, if you look at the zip structure it will be
Make sure that if you zip from File Explorer, you select files in the folder and not the folder itself. I see it happening all the time
You don’t need to run
composer install
manually. When acomposer.json
file is present, Elastic Beanstalk runscomposer.phar install
to install dependencies for you. And, when Elastic Beanstalk finds a vendor folder on the instance, it ignores thecomposer.json
file (even if it exists). Your application then uses dependencies from the vendor folder.Source: Installing your application’s dependencies
Further, in case you want to sets custom options to use when installing dependencies using Composer through
composer.phar
install, you can definescomposer_options
in theaws:elasticbeanstalk:container:php:phpini
namespace in the configuration file of.ebextensions
. For example:-.ebextensions/php-settings.config
sources:
Regarding the error, as you are trying to execute
composer install
with buildfile and hooks, it might not be running at the root of your application source code so it couldn’t find the composer.json file, so you might need to specify the absolute path of your composer.json with composer install, although I’m not very much sure on this part.I hope this helps.