change php version windows
How to upgrade php version on Windows 10
I’m trying to get my Laravel project to work. But when I use composer update it says the following:
This package requires php >=5.6.4 but your PHP version (5.5.12) does not satisfy that requirement.
I’ve searched a bit around on google and I found out that it uses my windows PHP version instead of my webserver’s version. But I couldn’t find out how to update my PHP version on Windows.
My PATH contents are as shown in the following image
4 Answers 4
You can uninstall composer, and while re-installing it will ask you to point at your PHP directory which is going to be C:\wamp64\bin\php (usually) at that point you can choose which PHP version you would want to use. good luck.
This means you have yet another installation of PHP in your system. Check your Programs in Control Panel and remove such installation.
However, you can modify your PATH environment variable as well. Procedure
Just remove the path that points to any PHP installation directory.
Else, otherwise, if you are unsure about changing the PATH variable (which can lead to serious problems if not set well), you can just delete the directory that the PATH variable points to. (I mean the PHP directory)
The totally better solution is to add the path of your PHP7 bin directory at the beginning of the PATH variable. You should also make available composer in this PHP7 bin directory.
Such as, replace the C:\php in your path with C:\wamp\bin\php7 or whatever the location of the PHP7 path is..
How to change PHP version used by composer
How can I use PHP7 without reinstalling the composer again?
9 Answers 9
You can change php version of composer without uninstalling it, follow these steps :
I’m assuming Windows if you’re using WAMP. Composer likely is just using the PHP set in your path: How to access PHP with the Command Line on Windows?
You should be able to change the path to PHP using the same instructions.
Otherwise, composer is just a PHAR file, you can download the PHAR and execute it using any PHP:
Use which composer command to help locate the composer executable.
Another possibility to make composer think you’re using the correct version of PHP is to add to the config section of a composer.json file a platform option, like this:
Where is the PHP version of your choice.
Snippet from the docs:
Lets you fake platform packages (PHP and extensions) so that you can emulate a production env or define your target platform in the config. Example: <"php": "7.0.3", "ext-something": "4.0.3">.
Old question I know, but just to add some additional information:
Note: It is important to understand that the «PHP CLI Version» is used by WAMP’s own internal PHP scripts. This «PHP CLI Version» has nothing to do with the version you wish to use for your scripts, Composer or anything else.
For your scripts to work with the version you require, you need to add it’s path to the Users Environmental Path. You could add it to the Systems environmental Path but the Users Path is the recommended option.
From WAMP v3.1.2, it would display an error when it detect reference to a PHP path in the System or User Environmental Path. This was to stop confusion such as you were experiencing. Since v3.1.7 the display of this error can now be optionally displayed through a selection in the WampSettings menu.
As indicated in previous answers, adding an installed PHP path (such as «C:\wamp64\bin\php\php7.2.30») to the Users Environmental Path is the correct approach. PS: As the value of the Users Environmental Path is a string, all paths added must be separated with a semi-colon (;)
After experiencing the exact same problem (IE: Choosing which version of PHP I wanted Composer to use), I created a script which could easily and rapidly switch between PHP CLI Versions depending on what project I was working on.
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:
For new project, I need to use nginx and installed PHP 7. The php is on:
Now, using GitBash MINGW32, I tried to install laravel 5.3 using Composer create-project but it said
I already put both C:\wamp\bin\php\php5.5.12 and C:\nginx\php on Windows System PATH variable.
How do I change the PHP version used by Composer?
2 Answers 2
Three ways to do this, really.
Something like alias ncomposer=`/path/to/php /path/to/composer.phar `
Specify the path to PHP version inside composer.phar itself
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.
In my case I have a folder named php733 inside xampp folder which corresponds to PHP 7.3.3. This is this other answer that helped me in creating the alias :
Finally, type this command in Git Bash :
Example : in the project that requires at least PHP 7.1.3
Using composer :
Using composer733 (the alias I created) :
It works, without having to change the environment variables
Change php version used by composer on windows #6277
Comments
crashbdx commented Mar 19, 2017
The text was updated successfully, but these errors were encountered:
We are unable to convert the task to an issue at this time. Please try again.
The issue was successfully created but we are unable to update the comment at this time.
alcohol commented Mar 20, 2017
I don’t understand why my composer is using a 5.4.45 php version
Please explain what this means, where this information comes from, or what you are basing this on. Because it makes zero sense without any actual context.
Seldaek commented Mar 20, 2017
@crashbdx the PATH value should contain the directory of the php.exe, not the full path including php.exe, just in case there is some confusion there.
Composer is not at fault in any case as this is OS/shell-level resolution.
denisdulici commented Jul 5, 2017
@crashbdx the only way is to uninstall and install it again 😉
@alcohol @Seldaek it would be nice if there were an option to change the following option without having to uninstall => install:
alcohol commented Jul 5, 2017
@denisdulici such requests should really be posted to composer/windows-setup. Then @johnstevenson can have a look at it and see how feasible it is 🙂
treetechsuman commented Dec 25, 2017
the only way is to uninstall and install it again 😉 work for me
geeky3 commented Mar 9, 2018
You can change php version of composer without uninstalling it, follow these steps :
linslin commented Aug 3, 2018 •
This should do it if you have composer installed globally:
AndrasZiegenham commented Aug 17, 2018
DependencyResolver easily eats up over 1GB and 32bit php is limited to 2GB memory use and oddly enough I get fatal errors near 1.3GB, so I have to use a 64bit php just for composer.
So according to this (and this: composer/windows-setup#72) topic the devs apparently don’t care about this sort of problem and want you to change your whole system’s environment to a different php. noice.
The only workaround seems to be the one mentioned by @linslin even though one can end up with monsters like this (using GitBash on windows):
Really, am I supposed to write this instead of «composer update»? Legit.
RahulDey12 commented Feb 24, 2020

check out this i have composer installed and php command working on my pc but there is no php in path variable
stof commented Feb 24, 2020
@RahulDey12 check both the user list and the system list. Both provide values for the PATH variable.
jonathanlaf commented Aug 19, 2020
How to upgrade lower version to latest PHP version in XAMPP on Windows
It is not very complex but some time very essential when we need latest version of php for new project without changing the current local server settings.
so i am trying to cover the changing the version by keeping the old version manually.
PHP 7.0.0 is released on 3rd Dec. 2015. It comes with more strong features which I listing below:–
Now i am going to show how you will overcome this situation. my present php version is php-5.6.36
Step 1: First download the latest php version from http://windows.php.net/download#php-7.0 Download the VC14 x86 Thread Safe or VC14 x64 Thread Safe deciding upon your Windows version( x86 for 32-bit and x64 for 64-bit ). Next extract the zip file in a folder named php.
Step 2: Go to your XAMPP installation directory and rename your old php directory with old version prefix like php to php_5_6_36. Now copy & paste the extracted new php folder to here.
Step3: Next, open httpd-xampp.conf from XAMPP configuration.
On PHP-Module setup section, comment these two lines and add the two lines below
#
# PHP-Module setup
#
#LoadFile “D:/xampp/php/php5ts.dll”
#LoadModule php5_module “D:/xampp/php/php5apache2_4.dll”
LoadFile “D:/xampp/php/php7ts.dll”
LoadModule php7_module “D:/xampp/php/php7apache2_4.dll”
That’s it. Now restart your XAMPP server and keep coding.











