Cake php not reading .env file

Hello all,
I added a config/.env file with one line:
export MYSQL_USER=“root”

and in app.php Datasource section I have:

‘username’ => env(‘MYSQL_USER’,‘root1’)

cakephp (v3.3) seems not to be reading the file. It tries to connect with (deliberate) false username root1. Do I have to install a composer packege? From the documentation I understood that cakephp does this by default.

Any help ?

Thanks

In your bootstrap.php file, make sure you have lines 52-58 uncommented. They are commented out by default. This also assumes you are using the josegonzalez/dotenv package which does ship with Cake by default.

rsz_1screenshot_25

It throws the error “APP_NAME” has already been defined in getenv() as depicted in the uploaded screenshot.

Could you please help me?

My guess would be that you’ve already defined the APP_NAME value somewhere before this.

Also Make sure that your .env doesn’t include spaces between the assignment.
This works.

export APP_NAME="MyApp123"

This does not work.

export APP_NAME = "MyApp123"