简体   繁体   中英

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.

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

我一直在使用Docker完成此操作:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM