Skip to content

Commit

Permalink
Updates readme with WordPress environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
hasukmistry committed Apr 23, 2024
1 parent 8490d70 commit d111e91
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This plugin introduces following features:
- [Creating a Yaml File](#creating-a-yaml-file)
- [Changing a Config Dir](#changing-a-config-dir)
- [Changing a Config File](#changing-a-config-file)
- [Using an Environment Variables](#using-an-environment-variables)
- [Registering Services](#registering-services)
- [Examples](#examples)
- [License](#license)
Expand Down Expand Up @@ -79,6 +80,38 @@ add_filter( 'wp_dev_config_file', function( string $config_file ): string {
});
```

### Using an Environment Variables

This plugin also adds support for WordPress environment variables via a configuration file. By default following environment variables are supported,

- WP_ENVIRONMENT_TYPE
- DB_NAME
- DB_USER
- DB_PASSWORD
- DB_HOST
- DB_CHARSET
- DB_COLLATE
- WP_CONTENT_DIR
- WP_CONTENT_URL
- WP_PLUGIN_DIR
- WP_PLUGIN_URL
- WP_UPLOAD_DIR
- WP_UPLOAD_URL
- WP_SITE_URL
- WP_HOME_URL

When using it in the configuration file, **wp_env** should be prefixed with the above variable name.

For example,

```yaml
services:
myService:
class: MyService
arguments:
db: '%wp_env(DB_NAME)%'
```
## Registering Services
To register a service in the container make sure your service class has **__invoke()** method defined.
Expand Down

0 comments on commit d111e91

Please sign in to comment.