每当我尝试使用以下命令创建新的Symfony项目时:
composer create-project symfony/skeleton new_project
我在控制台中收到这些错误消息,但我不知道原因:
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!!
!! Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "C:\Users\ferra\Projects\PHPex\test_project/.env" environment file. in C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php:567
!! Stack trace:
!! #0 C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php(114): Symfony\Component\Dotenv\Dotenv->doLoad(false, Array)
!! #1 C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php(157): Symfony\Component\Dotenv\Dotenv->loadEnv('C:\\Users\\ferra\\...', 'APP_ENV', 'dev', Array, false)
!! #2 C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\runtime\SymfonyRuntime.php(107): Symfony\Component\Dotenv\Dotenv->bootEnv('C:\\Users\\ferra\\...', 'dev', Array, false)
!! #3 C:\Users\ferra\Projects\PHPex\test_project\vendor\autoload_runtime.php(23): Symfony\Component\Runtime\SymfonyRuntime->__construct(Array)
!! #4 C:\Users\ferra\Projects\PHPex\test_project\bin\console(11): require_once('C:\\Users\\ferra\\...')
!! #5 {main}
!! thrown in C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php on line 567
!! PHP Fatal error: Uncaught Symfony\Component\Dotenv\Exception\PathException: Unable to read the "C:\Users\ferra\Projects\PHPex\test_project/.env" environment file. in C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php:567
!! Stack trace:
!! #0 C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php(114): Symfony\Component\Dotenv\Dotenv->doLoad(false, Array)
!! #1 C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php(157): Symfony\Component\Dotenv\Dotenv->loadEnv('C:\\Users\\ferra\\...', 'APP_ENV', 'dev', Array, false)
!! #2 C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\runtime\SymfonyRuntime.php(107): Symfony\Component\Dotenv\Dotenv->bootEnv('C:\\Users\\ferra\\...', 'dev', Array, false)
!! #3 C:\Users\ferra\Projects\PHPex\test_project\vendor\autoload_runtime.php(23): Symfony\Component\Runtime\SymfonyRuntime->__construct(Array)
!! #4 C:\Users\ferra\Projects\PHPex\test_project\bin\console(11): require_once('C:\\Users\\ferra\\...')
!! #5 {main}
!! thrown in C:\Users\ferra\Projects\PHPex\test_project\vendor\symfony\dotenv\Dotenv.php on line 567
!!
Script @auto-scripts was called via post-update-cmd
以下命令:'symfony check:requirements'
显示我的系统已准备好运行Symfony项目:
> 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
Optional recommendations to improve your setup
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
当我尝试创建一个演示项目而不是一个常规项目(symfony new --demo new_project
)时,我没有收到任何错误。
有人知道是什么原因导致在创建一个新的常规Symfony项目时出现错误消息吗?任何形式的帮助都是非常感谢的。
2条答案
按热度按时间pvcm50d11#
目前唯一的解决方案是在项目的根目录下手动创建文件**.env**。
4c8rllxm2#
我在Composer版本1中遇到了这个错误。幸运的是,我能够通过更新到Composer的最新版本来修复这个问题。