2

Whenever I try to create a new Symfony project using the following command:

composer create-project symfony/skeleton new_project

I'm getting these error messages in the console and I have no idea what causes it:

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

The following command: 'symfony check:requirements' shows that my system is ready to run Symfony projects:

> 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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not getting any errors when I try to create a demo project instead of a regular one (symfony new --demo new_project).

Does anyone know what's causing the error message when trying to create a new regular Symfony project? Any kind of help is appreciated.

2
  • 1
    This is the second time in the past couple of days that I’ve heard Windows users having problems like this, I’ll see if I can repro on my machine. In the meantime, can you just manually create the .env file? Commented Jul 13, 2022 at 12:19
  • Thanks, I've created the .env file manually and I can run the app fine now. Commented Jul 13, 2022 at 14:10

2 Answers 2

4

The only solution at the moment is to create the file .env manualy at the root of your project.

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

Comments

0

I encountered the error in composer version 1. Fortunately, I was able to fix this issue by updating to the latest version of the composer.

sudo composer self-update --2

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.