-
Notifications
You must be signed in to change notification settings - Fork 28
5. Environment Variables
We tried to separate config from code as much as possible and environment variables are used to achieve this. The benefit is there's a single place (.env) to keep settings like database or other 3rd party credentials that isn't committed to your repository.
PHP dotenv is used to load the .env file. All variables
are then available in your app by the built-in getenv()
function, $_SERVER
,
or $_ENV
methods.
However, we added the env()
function helper, which handles simple type conversion
(such as converting the string 'True'
to the boolean true
). Furthermore, it allow you to pass a default
value directly to the function, so you don't need to write if()
cases, which makes config files much
more complex to read. So we recommend you use env()
as well for reading environment variables.
Currently, the following env vars are required:
DB_USER
DB_NAME
DB_PASSWORD
WP_HOME
WP_SITEURL
Also we moved WordPress salts to .env
as well. They are generated by Composer on create project command.
So each new project created will have new secure salts.
Next: Composer