How to use the .env() Configurations?

Hi guys, i see that cakephp/app intruduce the dot env configurations but i still can’t use it properly.

I do the configuration proposed by jose gonzalez here https://github.com/cakephp/app/issues/224#issuecomment-167267108

And i aspect that when i call env(‘DEBUG’) i get the value, but its not happen. i only can access the configuration in Configure::read(‘debug’) and here i have my value from .env file.

Another thing is that i aspect that if anything .env file is present, the app go to use the default one in config/app.php and not get me the error.

Somebody use this type of configurations? How i can do and how its work? I see this type of conf in Laravel and realy enjoy it.

Thank in advance for any help, have a nice day!

2 Likes

I didn’t know about .env files, I mostly use it this way
DEBUG=true bin/cake server
in linux when i want to try something in production, i don’t know if it works on windows

1 Like

Env vars are often used with Platform as a Service hosting like heroku where you put the environment vars into the application environment using tooling. However, you can do what @raul338 said, and all webservers include ways of setting environment variables for specific virtual hosts. Apache has Set-Env and nginx has fastcgi_param.

2 Likes