Laravel: Different Composer.json Files For Dev And Production

- 1 answer

I need to have 2 different composer.json files for dev and production because I am developing vendor packages (locally) and would like to keep my vendor packages symlinked on dev environment because it's much easier to maintain.

The composer.json files contain:

  • For development, it has symlinked repositories by path.
  • For production, it has private repositories on github.

NOTE: The vendor packages are in require, and not require-dev... So an composer update --no-dev will not work.

How could I set this up?

Usually, the .env file is where you set different environment variables. Is there a way to set a COMPOSER_PATH variable that would point to the 2 different files on prod or dev?



You could use environment variables to have more than one composer files like composer.json and composer-testing.json and use it in a terminal with:

COMPOSER=composer-testing.json php composer.phar install