I’m using powershell for windows and trying to temporarily run scripts from powershell with PHP 7 but it’s stuck on 5.5
I’ve run set PATH=%PATH%;"C:Program Files (x86)PHP7.0"
but when I do php -v
it’s still 5.5 for some reason
What am I doing wrong?
2
Answers
The simplest way I found is to use aliases to temporary switch between php versions from cmd and powershell.
example:
of course you have to change the php binary path to match your system.
If you’re using Windows 10, it would be much easier to do this from windows explorer.
Windows + R
to bring up the run windowsysdm.cpl
and press enter, this will bring up System propertiesGo to advanced tab, and you’ll see
Environment variables
button near the bottom of the page click on the buttonYou’ll see system variables on the new dialog, look of the variable named
Path
and double click on it, This will show you the list of Paths on your computerLook for the one with php on it, this is the variable used to search for your php executable, You can delete if there are multiple of those and keep the one you need, or add on to your will
Press Ok on all open dialogs
Open up a new powershell window and type
php -v
to checkIf you need both versions, add both paths to the Path variables, make sure the one you want as
php
command is before the other one,Then go to the folder containing php5.5, find php.exe, make a copy and rename it to php5.exe, this way you can access php 5.5 as
php5 -v
and php 7 asphp -v