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.

Answers 1

  • 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.


Related Articles