Vojta Svoboda
Vojta Svoboda

Reputation: 13

Composer install on AWS without development requirements

Is there some way how to override AWS Elastic BeanStalk default composer install command?

I want to run composer install --no-dev.

Upvotes: 1

Views: 1826

Answers (2)

ChrisP
ChrisP

Reputation: 21

What's above and in the official EBS documentation didn't work when I tried..

Here's what worked for me:

option_settings:
  - namespace:  aws:elasticbeanstalk:container:php:phpini
    option_name: composer_options
    value: --no-dev

Not sure if theres an error in the documentation at this link but I submitted a report on it.. http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP.container.html#php-namespaces

Upvotes: 1

Julian
Julian

Reputation: 9140

Yes, you can append extra flags to the composer command in AWS Beanstalk.

You need to create an extra config file in <app-root-dir>/.ebextensions/composer.config:

commands:
  10updateComposer:
    command: export COMPOSER_HOME=/root && /usr/bin/composer.phar self-update
option_settings:
  aws:elasticbeanstalk:application:environment:
    option_name: COMPOSER_HOME
    value: /root
  aws:elasticbeanstalk:container:php:phpini:
    composer_options: --no-dev

Whatever you put in composer_options will be appended to the composer command line.

You can verify this is executed correctly by looking at your /var/log/eb-activity.log file. Look out for something like this:

 ++ /opt/elasticbeanstalk/bin/get-config optionsettings -n aws:elasticbeanstalk:container:php:phpini -o composer_options
  + PHP_COMPOSER_OPTIONS=--no-dev
  + echo 'Found composer.json file. Attempting to install vendors.'
  Found composer.json file. Attempting to install vendors.
  + composer.phar install --no-ansi --no-interaction --no-dev

For more info you can read the Composer File section in the manual.

Upvotes: 1

Related Questions