1. Go to this page and download the library: Download kariricode/configurator 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/ */
aririCode\Configurator\Configuration;
use KaririCode\Configurator\Loader\JsonLoader;
use KaririCode\Configurator\Loader\PhpLoader;
use KaririCode\Configurator\Loader\YamlLoader;
$config = new Configuration();
$config->registerLoader(new PhpLoader());
$config->registerLoader(new JsonLoader());
$config->registerLoader(new YamlLoader());
// Load configuration files
$config->load(__DIR__ . '/../config/app.php');
$config->load(__DIR__ . '/../config/database.json');
$config->load(__DIR__ . '/../config/cache.yaml');
// Get a single configuration value
$appName = $config->get('app.name');
$dbHost = $config->get('database.host');
$cacheDriver = $config->get('cache.driver');
// Check if a configuration key exists
if ($config->has('app.debug')) {
// Do something
}
// Get all configuration values
$allConfig = $config->all();
use KaririCode\Configurator\Contract\Configurator\Loader;
class XmlLoader implements Loader
{
public function load(string $path): array
{
// Implementation for loading XML files
}
public function getTypes(): array
{
return ['xml'];
}
}
$config->registerLoader(new XmlLoader());
use KaririCode\Configurator\MergeStrategy\StrictMerge;
$config = new Configuration(
mergeStrategy: new StrictMerge()
);
use KaririCode\Configurator\Validator\AutoValidator;
$config = new Configuration(
validator: new AutoValidator()
);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.