skip to Main Content

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


  1. The simplest way I found is to use aliases to temporary switch between php versions from cmd and powershell.

    example:

    >alias set php Y:php_binariesphp-5.3.9-Win32-VC9-x86php.exe

    of course you have to change the php binary path to match your system.

    Login or Signup to reply.
  2. If you’re using Windows 10, it would be much easier to do this from windows explorer.

    • Press Windows + R to bring up the run window
    • Type in sysdm.cpl and press enter, this will bring up System properties
    • Go to advanced tab, and you’ll see Environment variables button near the bottom of the page click on the button

    • You’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 computer

    • Look 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 check

    If 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 as php -v

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search