https://github.com/clearcodehq/wordpress-config
https://github.com/clearcodehq/wordpress-config
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/clearcodehq/wordpress-config
- Owner: ClearcodeHQ
- License: gpl-3.0
- Created: 2018-10-10T11:33:34.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-16T11:50:14.000Z (over 5 years ago)
- Last Synced: 2025-03-30T13:37:09.759Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Clearcode WordPress Config
Automagically define WordPress [configuration constants](https://codex.wordpress.org/Editing_wp-config.php) from [environment variables](http://php.net/manual/en/reserved.variables.environment.php) and `.env` file.
# Installation
```shell
$ composer require clearcode/wordpress-config
```
# Usage
Copy `wp-config.php` file to WordPress' root directory.
Create `.env` file and fill in the missing content:
```shell
DB_NAME=''
DB_USER=''
DB_PASSWORD=''
DB_HOST='localhost'
DB_CHARSET='utf8mb4'
DB_COLLATE=''
DB_PREFIX='wp_'
AUTH_KEY=''
SECURE_AUTH_KEY=''
LOGGED_IN_KEY=''
NONCE_KEY=''
AUTH_SALT=''
SECURE_AUTH_SALT=''
LOGGED_IN_SALT=''
NONCE_SALT=''
WP_VARS=''
```
You can also use environment variables that you have set in your `.env` file via a command line script, by using `source` it into your local shell session:
```shell
$ source .env
```
Instead of `.env` file you can use environment variables e.g. defined in you Apache server vhost configuration file:
```shell
...
SetEnv DB_NAME ''
SetEnv DB_USER ''
SetEnv DB_PASSWORD ''
SetEnv DB_HOST 'localhost'
SetEnv DB_CHARSET 'utf8mb4'
SetEnv DB_COLLATE ''
SetEnv DB_PREFIX 'wp_'
SetEnv AUTH_KEY ''
SetEnv SECURE_AUTH_KEY ''
SetEnv LOGGED_IN_KEY ''
SetEnv NONCE_KEY ''
SetEnv AUTH_SALT ''
SetEnv SECURE_AUTH_SALT ''
SetEnv LOGGED_IN_SALT ''
SetEnv NONCE_SALT ''
SetEnv WP_VARS ''
...
```
You can use all WordPress configuration constants, optionally you can add your own variables, but if you want to convert them from environment variables to PHP constants, you need to add them to `WP_VARS` environment variable, separated by coma.
# License
GPL3.0+ see [LICENSE.txt](LICENSE.txt) and [AUTHORS.txt](AUTHORS.txt)