1. Go to this page and download the library: Download xy2z/lite-config 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/ */
# No key prefix
Config::loadFile('config/settings.php');
echo Config::get('key');
# Prefix filename to key
Config::loadFile('config/db.ini', true);
echo Config::get('db.key');
use xy2z\LiteConfig\LiteConfig as Config;
use Symfony\Component\Yaml\Yaml;
Config::loadArray(Yaml::parseFile(__DIR__ . '/config/file.yml'));
echo Config::get('key');
use xy2z\LiteConfig\LiteConfig;
use Symfony\Component\Yaml\Yaml;
class CustomLiteConfig extends LiteConfig {
protected static function custom_handler(string $extension, string $path) {
if (($extension === 'yml') || ($extension === 'yaml')) {
return Yaml::parseFile($path);
}
// Handle other extensions here...
}
}
CustomLiteConfig::loadDir(__DIR__ . '/config', true);
var_dump(CustomLiteConfig::all());
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.