The environment file is invalid!Failed to parse dotenv file. Encountered an invalid name at {your env code}

Posted by

Problem:- When i run Composer install command in my laravel project to upgrade my project version after adding all the dependencies i got this env error

The environment file is invalid!
Failed to parse dotenv file. Encountered an invalid name at [GET-ALL-QUOTE-BY-FIRM].

Below is my env file

The Solution is:

The problem most likely stems from the rule that special characters and spaces shouldn’t be used in variable names in.env files. In most configuration systems, variable names like GET-ALL-QUOTE-BY-FIRM and others with similar formats are invalid.

You should change the names to adhere to the accepted variable naming guidelines in order to fix this problem. Variable names should normally only contain underscores, numerals, and capital letters. For instance, you can use underscores in place of hyphens:


By Doing these steps you have to run composer install command:

composer install

Now you error will be solved and your laravel project will run.

Leave a Reply

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

Would love your thoughts, please comment.x