Changing the version of PHP used by Composer for Windows

I have already used WAMP 2.5 with PHP 5.5.12 and with Composer. Php enabled:

C:\wamp\bin\php\php5.5.12 

For a new project, I need to use nginx and install PHP 7. Php is enabled:

 C:\nginx\php 

Now, using GitBash MINGW32, I tried to install laravel 5.3 using Composer create-project , but he 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:\wamp\bin\php\php5.5.12 and C:\nginx\php in the Windows System PATH variable.

How to change the version of PHP used by Composer?

+6
source share
1 answer

Three ways to do this, really.

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

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

Specify the path to the PHP version inside composer.phar itself

This is indicated at the beginning of the file: #!/path/to/php php . Then the composer should work with composer.phar

NB! The line will disappear with self-renewal, so this is not a reliable solution.

Move path using new PHP version

If you put C:\nginx\php first, it should be used by default when using composer.

Hope this helps!

+8
source

All Articles