Understanding the .env file
What is a .env file in PHP and why maybe not to use on fortrabbit.
# The .env file
The .env file format is a plain text configuration file that lives on top level of your code base. It has KEY=VALUE pairs, is easy to write for humans and runtime agnostic. You need an additional parser library, that reads the file and makes the ENV vars accessible from the code base. Here are the most popular .env parsers for PHP:
- github.com/vlucas/phpdotenv - Everyone
- github.com/symfony/dotenv - Symfony
Modern PHP frameworks like Laravel and Symfony …) and some CMS like Craft CMS use .env files for configuration and include a parser already.
# Don't put .env files on the server
Use a .env file the local development environment. Use pre-configured ENV vars from the fortrabbit dashboard, add custom ones via the dashboard. BUT PLEASE DON't put .env files on fortrabbit. Avoid confusion about conflicting sources and increase security.
Many CMS and frameworks will parse that file automatically. Now depending on the configuration set by the parser, the ENV vars from the .env file may or may not overwrite the values provided by the fortrabbit dashboard. To avoid mixed states, either use the ENV vars provided by the dashboard (recommended) or an .env file.
We highly recommend to NOT include a .env with your Git repo for obvious security concerns. The .env file can include secrets about your application. You can manually create or copy a .env file by SSH/SFTP. This might be automated. In that case, you may remove all custom ENV vars from the dashboard. Please see ENV var security.
Found a tpyo?Edit