For a Laravel app using docker-compose I have the following (simplified) folder structure:
Project
|
|-- data
|-- ...
|-- docker
|-- ...
|-- laravel
|-- app
|-- ...
|-- .env
|-- docker-compose.yml
|-- .env
Docker-compose is set up to load database connection details from the .env file in the root folder of the project when constructing the containers. Laravel also needs these and I have to duplicate them in the .env file inside the laravel folder.
I would like to avoid this duplication. Ideally I would load both .env files in Laravel to avoid cluttering up the docker-compose .env with stuff that is only relevant to Laravel. But I would be almost as happy to just have the one .env file in the project root, provided there is a clean way to do it.
I have found no configuration setting but relevant methods loadEnvironmentFrom() and useEnvironmentPath() inside the Illuminate\Foundation\Application but I'm not sure where to call them from. I would extend Application, but it seems that Dotenv is already loaded by the time it is instantiated in /boostrap/app.php
Hopefully there is somewhere outside of the vendor dolder where I could change the path or load a different .env file in time for it to be used by the configuration files. Help is greatly appreciated