0

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?

13
  • 2
    If you want the cli version, this has nothing to do with apache. Commented Jun 24, 2021 at 7:49
  • Okay, thank you but how do I change the cli version? Commented Jun 24, 2021 at 7:56
  • If you need another PHP version for CLI only... then download PHP from windows.php.net (since you are on Windows OS) and do a minimal needed configuration in php.ini. Commented Jun 24, 2021 at 7:58
  • If it has to be the part of XAMPP (so they both can use 2 diff PHP) .. then it's a diff question. In any case: the path to PHP executable should be different for different versions. Type where php to see the current path for php executable (e.g. when you run php.exe artisan xx command from Laravel or alike). The terminal (to be precise: Windows) looks for executable from folders from PATH environment variable. If you need to put your PHP version for CLI -- prepend such path there .. or use full path to the executable file. Commented Jun 24, 2021 at 8:03
  • Well it's a Symfony application that I need to run locally. I intended to use the Symfony local symfony.com/doc/current/setup/symfony_server.html, but that is to open in the browser, right? I need to update composer packages first, and I get the error that my PHP version is too recent, that's why I need a 7.0 CLI. I already downloaded PHP 7 for windows and tried to configure it in PhpStorm. I don't see the relation to "do a minimal needed configuration in php.ini" though. Commented Jun 24, 2021 at 8:05

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.