Michaël Gallego

This is my blog. What can you expect here? Well... Zend Framework 2, Amazon AWS...

Twitter

Google+

LinkedIn

Github

Last.fm

Solving the Elastic Beanstalk Composer deployment problems

I stumbled on a strange problem today while deploying a very simple application to AWS Elastic Beanstalk. No matter what I did, Composer command failed (saying that your requirements could not be resolved to an installable set of packages).

I spent at least two hours before finding why it worked on my other applications, and not on this one. The reason is that the built-in Composer that is bundled with Elastic Beanstalk is completely out of date (please Amazon, update it!).

There are two ways to solve this problem:

1) Make sure to upload the composer.lock file (this is why my previous applications could be deployed without problems!). By default, Zend Skeleton Application has this file in .gitignore, so make sure to remove it from the .gitignore.

2) If you absolutely need to remove the composer.lock file, add the following lines in an extension config file (to do this, create an .ebextensions folder at the root of your project, and add a file that has the .config extension):

commands:
  01_update_composer:
    command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update

option_settings:
  - namespace: aws:elasticbeanstalk:application:environment
    option_name: COMPOSER_HOME
    value: /root

Those commands will make sure to update Composer, and to set the environment variable.

There are a few other ways why your Elatic Beanstalk may failed. Elastic Beanstalk automatically uses Composer if and only your application does not have a /vendor folder. Therefore, you must make sure that your .gitignore is properly configured to not commit the vendor folder at all.

I hope it helps!