Fresh bedrock install - PHP Error "DB_NAME missing in validator.php"

Hello!

This is getting really frustrating now and i dont know why its happening, hopefully someone of you can help me!

Set up bedrock running a git clone and then composer install and after that configuring my .env as below. Without the .env file i get a standard wordpress message stating “Could not connect to the database” nothing fancy, but after i sat up my .env i get a message stating

( ! ) Fatal error: Uncaught exception 'RuntimeException' with message 'One or more environment variables failed assertions: DB_NAME is missing' in C:\NotSourceControl\SageDemo\bedrock\vendor\vlucas\phpdotenv\src\Validator.php on line 102
( ! ) RuntimeException: One or more environment variables failed assertions: DB_NAME is missing in C:\NotSourceControl\SageDemo\bedrock\vendor\vlucas\phpdotenv\src\Validator.php on line 102

And i dont get why since i clearly have stated the db_name in the env file that looks like this

DB_NAME=SageDemo
DB_USER=SageDemo
DB_PASSWORD=xxxxxxxx
DB_HOST=www.xxxxx.com

WP_ENV=development
WP_HOME=http://localhost:1020
WP_SITEURL=http://localhost:1020/wp

the .env file is located directly under the Bedrock folder as instructed.

Thanks in advance for any help!
Petter

Solved it myself by misstake.

The problemwas not having a blank row at the very top of the .env file. Seems like the first row isn’t read for some reason…really strange.

UPDATE

Found out the issue, the file was saved as UTF-8. Changed it to ANSI and removed the top blank line and it still works!!

1 Like