Parris Varney
Parris Varney

Reputation: 11478

Targeting a different php version with Composer

Is there a way to do a Composer build with a php version different from what is installed locally?

My use case is that I have a development container using php56 which lives on a host that has php54. The two environments have a shared folder where the project files live, and I do my builds from an IDE living on the host machine (which uses 5.4).

In a perfect world, I would just upgrade my host to 5.6, but I work on some projects with the lower version.

Upvotes: 2

Views: 490

Answers (2)

Parris Varney
Parris Varney

Reputation: 11478

I've been accomplishing this using Docker:

docker run -v $(pwd):/app composer/composer update

Upvotes: 0

Mitchell Olsthoorn
Mitchell Olsthoorn

Reputation: 181

I don't think you can change that because composer uses the php version that composer is run with, so there are only a few options

  • Install the required php version as extra installation (as you already did)
  • Change the source of composer where the version is taken from the php environment (not really a good idea)
  • Maybe installing the dependencies from your development box, because you said that you had a shared folder between the systems

The last option is the most promising in my opinion because linux has very nice support for hosting multiple versions of php with phpenv

Sorry I couldn't give you a real solution

Upvotes: 2

Related Questions