skip to Main Content

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 ?

2

Answers


  1. I just had this problem on my Windows environment. For some reason, symfony is not reading .php-version correctly when I create it using echo "7.2" > .php-version.

    The problem was gone once I deleted and created a new text file from my IDE. Probably creating it using vscode code .php-version or using the File Explorer would work too (I didn’t try it, yet).

    Edit: I just tried creating the file with VS Code and Notepad – Both worked. But I still don’t know why it doesn’t work when creating with echo

    Edit2: I think I got it. Looks like PowerShell’s echo "" > file will create the file with UTF-16 encoding. After converting the file to UTF-8 it worked as expected.

    Login or Signup to reply.
  2. Just delete your .php-version file and create in manually from your ide! With the from encoding (using echo from terminal) the error message was

    the current dir requires PHP ��7.4.10
    

    you can see the encoding is wrong by the question marks.
    Creating the file from the ide fixed my problem!

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