Cannot change PHP default version in Symfony 4.12

I would like to create a Symfony project. I have the same issue as many people concerning php version: Symfony uses the wrong one.

λ php -version
PHP 7.4.1 (cli) (built: Dec 17 2019 19:24:02) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

λ symfony -V
Symfony CLI version v4.12.4 (Tue Jan 14 13:09:08 UTC 2020)

λ symfony check:requirements

Symfony Requirements Checker
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> PHP is using the following php.ini file:
C:xamppphpphp.ini

> Checking Symfony requirements:

..............WWW......W..


 [OK]
 Your system is ready to run Symfony projects

I have Xampp installed but I use Laragon with 7.4.1 on Windows 10 and wish to use that one, but Symfony tells me this:

λ symfony local:php:list
┌─────────┬─────────────────────────────────────────────┬─────────┬─────────┬─────────────┬─────────┬─────────┐
│ Version │                  Directory                  │ PHP CLI │ PHP FPM │   PHP CGI   │ Server  │ System? │
├─────────┼─────────────────────────────────────────────┼─────────┼─────────┼─────────────┼─────────┼─────────┤
│ 7.3.10  │ C:xamppphp                                │ php.exe │         │ php-cgi.exe │ PHP CGI │ *       │
│ 7.4.1   │ C:laragonbinphpphp-7.4.1-Win32-vc15-x64 │ php.exe │         │ php-cgi.exe │ PHP CGI │         │
└─────────┴─────────────────────────────────────────────┴─────────┴─────────┴─────────────┴─────────┴─────────┘

The current PHP version is selected from default version in $PATH

Even though there is no trace of Xampp or php 7.3.1 in my $PATH.

λ echo %path:;=&echo.%
C:Program Filescmder_minibin
C:Program Filescmder_minivendorbin
C:Program Filescmder_minivendorconemu-maximus5ConEmuScripts
C:Program Filescmder_minivendorconemu-maximus5
C:Program Filescmder_minivendorconemu-maximus5ConEmu
C:Program Files (x86)Common FilesOracleJavajavapath
C:Windowssystem32
C:Windows
C:WindowsSystem32Wbem
C:WindowsSystem32WindowsPowerShellv1.0
C:WindowsSystem32OpenSSH
C:Program Filesnodejs
C:Program FilesGitcmd
C:ProgramDataComposerSetupbin
C:laragonbinphpphp-7.4.1-Win32-vc15-x64php.exe
C:Program FilesSymfony
C:laragonbin
C:laragonbinapachehttpd-2.4.35-win64-VC15bin
C:laragonbincomposer
C:laragonbinlaragonutils
C:laragonbinmysqlmysql-5.7.24-winx64bin
C:laragonbinnginxnginx-1.16.0
C:laragonbinngrok
C:laragonbinnotepad++
C:laragonbinphpphp-7.4.1-Win32-vc15-x64
C:laragonbinputty
C:laragonbinredisredis-x64-3.2.100
C:laragonbintelnet
C:laragonusrbin
C:Program FilesSublime Text 3
C:UsersUserAppDataLocalYarnconfigglobalnode_modules.bin
C:UsersUserAppDataRoamingComposervendorbin
C:UsersUserAppDataRoamingnpm
C:Ruby26-x64bin
C:UsersUserAppDataLocalMicrosoftWindowsApps
C:Program FilesJetBrainsPhpStorm 2019.2.3bin
C:Program FilesJetBrainsDataGrip 2019.2.5bin
C:Program FilesGitcmd
C:Program FilesGitmingw64bin
C:Program FilesGitusrbin
C:Program Filescmder_mini

(I checked user & system $PATH)

I tried to force Symfony into using 7.4.1 by running in a project directory:

λ echo "7.4.1" > .phpversion

When I run

λ symfony local:php:refresh

λ symfony local:php:list

I get:

λ WARNING the current dir requires PHP "7.4.1" (.php-version from current dir: C:laragonwwwCMS_test.php-version), but this version is not available

I also tried renaming the Xampp directory name, and as a matter of fact, that “works”.

C:
λ symfony check:requirements
php does not seem to be available under C:xamppphp


C:
λ symfony local:php:list
┌─────────┬─────────────────────────────────────────────┬─────────┬─────────┬─────────────┬─────────┬─────────┐
│ Version │                  Directory                  │ PHP CLI │ PHP FPM │   PHP CGI   │ Server  │ System? │
├─────────┼─────────────────────────────────────────────┼─────────┼─────────┼─────────────┼─────────┼─────────┤
│ 7.4.1   │ C:laragonbinphpphp-7.4.1-Win32-vc15-x64 │ php.exe │         │ php-cgi.exe │ PHP CGI │ *       │
└─────────┴─────────────────────────────────────────────┴─────────┴─────────┴─────────────┴─────────┴─────────┘

The current PHP version is selected from default version in $PATH

But that solution isn’t really satisfying to me.

I’ve search StackOverflow for several hours, tried to re-install Symfony, restart the computer, ask friends etc no one seem to have another solution.

So, why does Symfony search for php in a Xampp directory ? Is it possible to choose another default one like Laragon’s ? Any idea ?

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *