Closed kabarakh closed 6 years ago
Hey @kabarakh. Thanks for taking the time to create a pull request.
I have some questions.
The idea of a composer.json file is to clone it to a system and use composer install
to replicate a working state for the application on that system.
Since this is only about code and an application needs configuration as well and some configuration is environment specific, the idea is to let the application pull in environment specific configuration from the environment.
So to get the application running you do composer install
, then set the environment values config and you can then run the application. The idea behind .env is exactly that and additionally makes it easy to set environment variables.
Long explanation short: composer.json is portable, .env is system/environment specific.
Your change now proposes to put environment specific config (an absolute path) into composer.json, which would violate the concept.
Maybe I got it wrong. Can you elaborate on your specific use case?
Hi @helhum,
we are using .env in a multi-application, multi-server environment where potentially multiple applications share a server. The .env is built by Ansible and put inside of /var/www/, the apps are put within /var/www/appName. Because we use Surf to deploy, on the remote servers we got releases/current-directories, which we don't have in development. But Ansible generates a .env for both. Because the relative path differs between the systems, we need an absolute path (which is the same on all of our projects by convention, and outside of webroot for security) to access the .env
Thanks for the explanation. I still don't fully understand why your ansible recipies cannot link or copy the .env to the correct location, as hopefully you applications don't have the composer.json exposed in document root, but in general it might be legit to also configure an absolute path to the env file for specific use cases.
Have you investigated why
$pathToEnvFileCode = $this->filesystem->findShortestPathCode(
$this->includeFile,
$envFile
);
fails if $envFile
is an absolute path? From looking at the code it should work.
Hi @helhum,
I'll close this merge request
1.) A coworker told me that absolute paths wouldn't work, I'm guessing he tried the 2.0.0 version (which had a dirname which you did remove). But trying out 2.0.2 it works correctly. 2.) We discussed our structure and will try other solutions/.env-locations. ;)
Gruß, Christian Herberger
Alright, thanks Christian
this is useful if the .env is outside of the project, so the project path can be changed but .env is still loaded