Change PHP version used by Composer on Windows

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:\nginx\php first, it should be used by default when using composer.

Hope this helps!

Leave a Comment