Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
13.3k views
in Technique[技术] by (71.8m points)

laravel - Change PHP version used by Composer on Windows

I have already use WAMP 2.5 with PHP 5.5.12, and with Composer. The php is on:

C:wampinphpphp5.5.12

For new project, I need to use nginx and installed PHP 7. The php is on:

C:
ginxphp

Now, using GitBash MINGW32, I tried to install laravel 5.3 using Composer create-project but it said

[InvalidArgumentException]
Could not find package laravel/laravel with version 5.3 in a version 
installable using your PHP version 5.5.12.

I already put both C:wampinphpphp5.5.12 and C: ginxphp on Windows System PATH variable.

How do I change the PHP version used by Composer?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Three ways to do this, really.

Create an alias in .bashrc to always run composer with the corresponding version

Something like alias ncomposer=`/path/to/php /path/to/composer.phar `

Specify the path to PHP version inside composer.phar itself

This is specified at the start of the file: #!/path/to/php php. Then composer should run with composer.phar

NB! The line will disappear upon self-update, so it's not a reliable solution.

Move up the path with the newest PHP version

If you place C: ginxphp first, it should be used by default when using composer.

Hope this helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...