1. Go to this page and download the library: Download puzzle/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/ */
puzzle / configuration example snippets
class Example
{
public function __construct(Puzzle\Configuration $config)
{
$threshold = $config->read('app/detection/threshold');
}
}
$fileSystem = new Gaufrette\Filesystem(
new Local('path/to/yaml/files/root/dir')
);
$config = new Puzzle\Configuration\Yaml($fileSystem);
$example = new Example($config);
$config = new Puzzle\Configuration\Memory(array(
'app/detection/threshold' => 2
);
$example = new ExampleTest($config);
$configuration->read('a/b/c', 'default value if a/b/c does not exist');
// will throw an exception if a/b/c does not exist
$configuration->readRequired('a/b/c');
// Since 1.5.0
// returns value associated to first existing key
// will throw an exception if none exist
$configuration->readFirstExisting('a/b/c', 'd/e/f', 'x/y/z');
// Since 1.6.0
$defaultFileSystem = new Gaufrette\Filesystem(
new Local('path/to/yaml/files/root/dir')
);
$defaultConfig = new Puzzle\Configuration\Yaml($defaultFileSystem);
$fileSystem = new Gaufrette\Filesystem(
new Local('path/to/another/config/files')
);
$localConfig = new Puzzle\Configuration\Yaml($fileSystem);
$config = new Puzzle\Configuration\Stacked();
$config->overrideBy($defaultConfig)
->overrideBy($localConfig);
// values will be read in localConfig first. They will be read in default config only if they don't exist in local one.
$fileSystem = new Gaufrette\Filesystem(
new Local('path/to/yaml/files/root/dir')
);
$defaultConfig = new Puzzle\Configuration\Yaml($fileSystem);
$overrideConfig = new Puzzle\Configuration\Memory(array(
'app/detection/threshold' => 2
);
$config = new Puzzle\Configuration\Stacked();
$config->overrideBy($defaultConfig)
->overrideBy($overrideConfig);
// Since 2.0.0
$config = new Puzzle\Configuration\Stacked();
$config->overrideBy($overrideConfig)
->addBase($defaultConfig);
// Since 1.7.0
$fileSystem = new Gaufrette\Filesystem(
new Local('path/to/yaml/files/root/dir')
);
$config = new Puzzle\Configuration\Yaml($fileSystem);
$config = new Puzzle\PrefixedConfiguration($config, "logger/$loggerName");
$filename = $config->readRequired('filename');
$verbosity = $config->readRequired('verbosity');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.