我想创建一个 Symfony 项目。关于 php 版本,我和许多人有同样的问题:Symfony 使用了错误的版本。
λ 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:\xampp\php\php.ini
> Checking Symfony requirements:
..............WWW......W..
[OK]
Your system is ready to run Symfony projects
我安装了 Xampp,但我在 Windows 10 上使用带有 7.4.1 的 Laragon 并希望使用那个,但 Symfony 告诉我:
λ symfony local:php:list
┌─────────┬─────────────────────────────────────────────┬─────────┬─────────┬─────────────┬─────────┬─────────┐
│ Version │ Directory │ PHP CLI │ PHP FPM │ PHP CGI │ Server │ System? │
├─────────┼─────────────────────────────────────────────┼─────────┼─────────┼─────────────┼─────────┼─────────┤
│ 7.3.10 │ C:\xampp\php │ php.exe │ │ php-cgi.exe │ PHP CGI │ * │
│ 7.4.1 │ C:\laragon\bin\php\php-7.4.1-Win32-vc15-x64 │ php.exe │ │ php-cgi.exe │ PHP CGI │ │
└─────────┴─────────────────────────────────────────────┴─────────┴─────────┴─────────────┴─────────┴─────────┘
The current PHP version is selected from default version in $PATH
即使在我的 $PATH 中没有 Xampp 或 php 7.3.1 的痕迹。
λ echo %path:;=&echo.%
C:\Program Files\cmder_mini\bin
C:\Program Files\cmder_mini\vendor\bin
C:\Program Files\cmder_mini\vendor\conemu-maximus5\ConEmu\Scripts
C:\Program Files\cmder_mini\vendor\conemu-maximus5
C:\Program Files\cmder_mini\vendor\conemu-maximus5\ConEmu
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Program Files\nodejs\
C:\Program Files\Git\cmd
我试图通过在项目目录中运行来强制 Symfony 使用 7.4.1:
λ echo "7.4.1" > .phpversion
月关宝盒
largeQ