3

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?

4
  • 1
    Assuming your composer.json is checked in, maybe use a different branch in dev? Commented May 22, 2019 at 19:14
  • You may end up with different dependencies installed on dev environment than on production. You will lose main advantage of composer.lock. Commented May 22, 2019 at 21:34
  • 1
    Good idea @adam, thx. @rob006, I don't see any major disadvantages: prod will use composer.lock and dev composer-testing.lock. Am I missing anything else? Commented May 22, 2019 at 22:01
  • You can continue to use the same lock. The only difference in the lock on dev will be the first party(your) vendor packages in development. The point of the lock is to keep third party vendor packages in check. Commented May 22, 2019 at 22:30

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.