Answer the question
In order to leave comments, you need to log in
How do the variables from the .env file for Docker get into $_ENV?
There is a PHP project in the form of a git repository.
It is proposed to deploy it through docker.
There are default settings in the docker configs, the project opens on localhost.
The config.php in the project uses data from $_ENV, which, when run through docker, magically turns out to be filled with the necessary data from the .env file.
Only one snag.
Configs are not allowed to be changed.
But it's uncomfortable for me.
I have Linux on my machine (lamp and that's all) and deploying the same project without using docker, with my own host name , is a little easier and faster and more convenient for me personally for development. And my localhost is busy with something else.
I do not have the right to add any of the "Dot Env" type libraries to the project to process the .env file.
And there is no such thing in the project.
So how can I make sure that without running the project through docker, my $_ENV is magically filled with data from the .env file (without adding additional libraries and files to the project to process .env )?
How does it happen in a container?
Answer the question
In order to leave comments, you need to log in
It is written what it is and where it comes from
https://www.php.net/manual/ru/reserved.variables.e...
Tamara Lamova Tamara Lamova Asker Just
added to /etc/apache2/envvars , restarted Apache.
It worked.
SetEnv SPECIAL_PATH /example/test
SetEnv APPLICATION_ENV production
location / {
...
fastcgi_param APPLICATION_ENV production;
fastcgi_param SPECIAL_PATH /example/test;
...
}
env APP_NAME=MyAPP php -r 'var_dump(getenv("APP_NAME"));'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question