Like Bedrock does. A common configuration file using environment variables or using dotenv allowing to define db passwords and salts.
Special configuration files for each environment :
development
staging
production
Voters
+25 more
Tags
Request: Add feature
Discussion
Adam Alicki
· September 7, 2018 · 15:38
This would go a long way in developing locally vs. production (for those of us who have to deal with on-server files).
James Nylen
· September 7, 2018 · 16:56
· edited
There are a number of better ways to solve this than multiple config files (lots of duplication). My favorite is https://github.com/vlucas/phpdotenv.
The way it works is you create a .env file for each environment, then in your wp-config.php file, you set the defines up like this:
define( 'DB_NAME', getenv( 'DB_NAME' ) );
I would be fine with us making an official recommendation here, or making a setup like this easier.
James Nylen
· September 7, 2018 · 18:50
· edited
.
Alan
· September 8, 2018 · 13:05
· edited
Exactly, but both goes hand in hand. You need .env to avoid storing db access in your project codebase, but multiple file per environment are useful because it can sometimes be annoying to add a lot of .env vars that are not that sensitive.
The simpler example are the debug display options that you may want set per environment and then forget.
Mike Schinkel
· October 26, 2018 · 04:47
Effectively though, isn't this petition not so much "one configuration file per environment" but instead "Solve the problems associated with dev/test/stage/prod?"
This would go a long way in developing locally vs. production (for those of us who have to deal with on-server files).
There are a number of better ways to solve this than multiple config files (lots of duplication). My favorite is https://github.com/vlucas/phpdotenv.
The way it works is you create a
.env
file for each environment, then in yourwp-config.php
file, you set the defines up like this:define( 'DB_NAME', getenv( 'DB_NAME' ) );
I would be fine with us making an official recommendation here, or making a setup like this easier.
.
Exactly, but both goes hand in hand. You need .env to avoid storing db access in your project codebase, but multiple file per environment are useful because it can sometimes be annoying to add a lot of .env vars that are not that sensitive.
The simpler example are the debug display options that you may want set per environment and then forget.
Effectively though, isn't this petition not so much "one configuration file per environment" but instead "Solve the problems associated with dev/test/stage/prod?"
Semi-related, at minimum: Define WP_ENV constant by default (after wp-config.php loaded, ofc)...
<code><pre>if( !defined( 'WP_ENV' ) ) define( 'WP_ENV', 'production' );</pre></code>