In App Platform for PHP Environment. How do i force the composer install to install the packages including dev?

Currently it looks like the installing dependencies process only installed the packages for prod and no dev. I tried to use build_command: composer install --dev in app spec.yml but no luck/still error.

As with Symfony Framework, there are “post-install-cmd” scripts where it’s executed after package installed and since the env are dev. It expected if the application have installed the package in “require-dev” part.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers


Usually, the recommendation is that if a dependency is needed to build the app for production, then it should be a regular dependency and not a dev dependency.

However, if you really want to, you can configure the build to install dev dependencies. I must say that this is not officially supported so there are no guarantees that this method will work forever. To install dev dependencies, add an environment variable called HEROKU_PHP_INSTALL_DEV with no value. Leave the value text field empty. This is very important otherwise it might break the build.

Again, I would recommend doing this only for testing. If it fixes the issue then I would recommend updating your composer.json and moving the necessary dependencies from require-dev to require (and removing the workaround).

  • Thank you @kamaln7 , this is what i looking for. Will try it and let you know if it works.

    I do agree ideally the app deployed should be prod env. But sometime in early development we still need test/dev environment for rapid development.

    I usually have 1 specific server with dev/test ENV for my dev & QA team to testing to view all the error before we escalate to staging ENV>

  • Hi @kamaln7 , sorry took me time to back to you. I just tried the HEROKU_PHP_INSTALL_DEV.

    Here are my example config

      - environment_slug: php
          - key: HEROKU_PHP_INSTALL_DEV
            scope: BUILD_TIME

    It success on build but unexpectedly it failed on deployments.

    The logs from deployments are

    [2021-04-16T13:36:40.975771222Z] DOCUMENT_ROOT changed to 'public/'
    [2021-04-16T13:36:41.907919488Z] Assuming 512MB of RAM
    [2021-04-16T13:36:42.032087145Z] PHP memory_limit is 128M Bytes
    [2021-04-16T13:36:42.175253959Z] Starting php-fpm with 4 workers...
    [2021-04-16T13:36:44.073718161Z] Starting httpd...
    [2021-04-16T13:36:44.857059668Z] Application ready for connections on port 8080.

    The logs info are weird, but I guess as you said, we can’t rely on this as it’s not officially supported.

    • Thanks for the update @budiarsana. These logs seem fine and I don’t see any errors, I think you might be viewing the logs for the rollback deployment. In the Deployments tab, click on the “Details” link for the spec update deployment and then view the Deploy logs

Hi, Personally I found more convenient to drop a Dockerfile into the root folder of the git repository and DO will build it for you. This is worked for me better.