Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.8 , artisan commands error : Failed to parse dotenv file due to an invalid name

This problem only happens with Laravel 5.8 on my shared hosting.

It is working fine in my shared hosting with Laravel 5.7.

It is working fine in my local environment with Laravel 5.8.

the problem is:

every time I run php artisan commands (on my shared hosting with Laravel 5.8 only) I got this error

The environment file is invalid! Failed to parse dotenv file due to an invalid name.

Failed at [APP_NAME].

my .env first line is : APP_NAME=rased

Also my site after updating to Laravel 5.8 is becoming a white blank page!

like image 285
Abdulaziz Tayyar Avatar asked Mar 13 '19 17:03

Abdulaziz Tayyar


People also ask

Why did my dotenv file fail to parse?

Failed to parse dotenv file due to unexpected whitespace. Failed at [This will fail]. In this example it was caused by having unescaped whitespace in the APP_NAME field i.e. To fix, escape with quotes e.g.

What does [this will fail] mean when parsing an environment file?

This is a general error related to parsing the .env file. You'll see this is indicated in the error e.g. The environment file is invalid! Failed to parse dotenv file due to unexpected whitespace. Failed at [This will fail].

Why is my site becoming a white blank page in Laravel?

Also my site after updating to Laravel 5.8 is becoming a white blank page! Show activity on this post. This is a general error related to parsing the .env file. You'll see this is indicated in the error e.g. The environment file is invalid! Failed to parse dotenv file due to unexpected whitespace. Failed at [This will fail].

What is environment file in Laravel?

Secured Applications have an environment file that contains data for specific machine and software configurations like Database name and password, Email and password, value to tell if it's for development or production, etc. Laravel loads them in constant accessible via global function env () .


2 Answers

This is a general error related to parsing the .env file. You'll see this is indicated in the error e.g.

The environment file is invalid!
Failed to parse dotenv file due to unexpected whitespace. 
Failed at [This will fail].

In this example it was caused by having unescaped whitespace in the APP_NAME field i.e.

APP_NAME=This will fail

To fix, escape with quotes e.g.

APP_NAME="This is better"
like image 50
Praj Basnet Avatar answered Sep 20 '22 09:09

Praj Basnet


This is general Error when we change our app name. To remove this error just do this.

APP_NAME=My Project Name 

to this

APP_NAME="My Project Name"

You just need to add "" course around name. Thanks

like image 30
Muhammad Wasim Akram Avatar answered Sep 17 '22 09:09

Muhammad Wasim Akram