Samuel Gfeller
Samuel Gfeller

Reputation: 1000

Change CLI PHP version for specific project

One project needs an older PHP version 7.0.

I followed this guide from JetBrains to configure the PHP Interpreter, but even after restarting Apache, terminating the shell, restarting PhpStorm it didn't work.

enter image description here

So I decided to try it differently, so I followed this guide on how to run two PHP versions at the same time with XAMPP, I followed everything to the letter, but when typing php -v it still does not show the wanted PHP version.

Am I missing out on something?

Upvotes: 0

Views: 2762

Answers (1)

Samuel Gfeller
Samuel Gfeller

Reputation: 1000

A thousand thanks to @LazyOne which gave me the solution.
As I only need PHP 7 to run composer update for one project, it is way simpler to use the full path instead of configuring the PATH env variable.
This worked for me:

  1. Install the right PHP version from here
  2. Extract the files in new folder (I called it php7)
  3. Copy php.ini-development to php.ini
  4. Open it and remove the ; before ; extension_dir = "ext" and ; extension=openssl
  5. Run the command with the full path
"C:\xampp\php7\php.exe" "C:\ProgramData\ComposerSetup\bin\composer.phar" update

Et voilà.

Unfortunately though, this didn't work out for me as I had many exceptions, but not really related to this question (Fatal error: Attempted to load class "Redis" from the global namespace) as the update command did start the update process.

Upvotes: 1

Related Questions