PHP code example of czproject / configuration
1. Go to this page and download the library: Download czproject/configuration library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
czproject / configuration example snippets php
use CzProject\Configuration\Configurator;
$configurator = new Configurator;
$configurator->addConfig(array(
'database' => array(
'host' => 'localhost',
),
));
$configurator->addConfig(array(
'database' => array(
'user' => 'user123',
'password' => 'password123',
),
));
$config = $configurator->getConfig();
/* Returns:
[
database => [
host => 'localhost',
user => 'user123',
password => 'password123',
]
]
*/
php
use CzProject\Configuration\Configurator;
$configurator = new Configurator;
$configurator->addConfig(array(
'parameters' => array(
'database' => array(
'host' => 'localhost',
'driver' => 'mysql',
),
),
'messages' => array(
'user' => '%database.user%',
),
));
$configurator->addConfig(array(
'parameters' => array(
'database' => array(
'user' => '%database.host%_user123',
'password' => 'password123',
),
),
));
$config = $configurator->getConfigExpandedBy('parameters');
/* Returns:
[
parameters => [
database => [
host => 'localhost',
driver => 'mysql',
user => 'localhost_user123',
password => 'password123',
]
],
messages => [
user => 'localhost_user123',
]
]
*/