Chapter 3. Configuration Adapters

For a basic understanding why adapters are useful, have a look at the configuration documentation.

You can build your own configuration adapter. Want to know how? Have a look at the extending PHPBU section

Environment adapter "env"

Adapter to use environment variables for option values.

Example 3.1: Adapter definition

  <adapter type="env" name="myName"></adapter>

Example 3.2: Adapter reference

  <option name="password" value="adapter:myName:SOME_ENV_VAR" />

Dotenv adapter "dotenv"

Adapter to use .env files to load environment variables.

Table 3.1. Options

fileno.envPath to the .env file 

Example 3.3: Adapter definition

  <adapter type="dotenv" name="myName">
    <option name="file" value="my-dot-env-dir/.env" />

Example 3.4: Adapter reference

  <option name="password" value="adapter:myName:SOME_DOTENV_VAR" />

PHP array adapter

Adapter to use PHP array config files.

Example 3.5: Example PHP array config file

<?php return ['foo' => ['bar' => 'baz']];

Table 3.2. Options

fileyes-Path to the php config file 

Example 3.6: Adapter definition

  <adapter type="array" name="myName">
    <option name="file" value="my-config-dir/config.php" />

Example 3.7: Adapter reference

  <option name="password" value="" />

PHP constant adapter

Adapter to use PHP constant config files.

Example 3.8: Example PHP constant config file

<?php define('DB_NAME', 'foo');

Table 3.3. Options

fileyes-Path to the php config file 

Example 3.9: Adapter definition

  <adapter type="constant" name="myName">
    <option name="file" value="my-config-dir/config.php" />

Example 3.10: Adapter reference

  <option name="password" value="adapter:myName:DB_NAME" />

Wordpress config adapter

Adapter to use wordpress config files.

Table 3.4. Options

fileyes-Path to the wordpress config file 

Example 3.11: Adapter definition

  <adapter type="wordpress" name="wp">
    <option name="file" value="wordpress/wp-config.php" />

Example 3.12: Adapter reference

  <option name="password" value="adapter:wp:DB_NAME" />

Please open a ticket on GitHub to suggest improvements to this page. Thanks!