Imagine if you have several different environments and the .env settings need to be dynamic when the project pass through each..
This small script was made to solve it.
But, i strong recommend to take a look on https://github.com/vlucas/phpdotenv for better soluctions.
The custumer use their projects with the follow flow:
local (windows) -> dev (Linux) -> Stage (Linux) -> Prod (Linux)
So, i've organized the .env name file according the table below:
Environment | S.O. | .env |
---|---|---|
Local | Windows | .env.local |
Dev | Linux | .env.dev |
Stage | Linux | .env.stage |
Production | Linux | .env.production |
- PS: You can use it wich how many files who goes to need, just adjust the DetectEnvironment->whichIs() method it.
- PS2: It was used at an Laravel project, i believe it can be implemented for other needs.
*Please, let me know if you have any suggestion.