PHP code example of fastd / config
1. Go to this page and download the library: Download fastd/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/ */
fastd / config example snippets
FastD\Config\FileParser;
// 创建解析器实例
$parser = new FileParser();
// 解析配置文件
$config = $parser->parse('config/app.json');
// 访问配置值
echo $config->get('database.host');
// 配置文件中使用变量
// database:
// host: "%db_host%"
// port: "%db_port%"
$variables = [
'db_host' => 'localhost',
'db_port' => 3306
];
$parser = new FileParser($variables);
$config = $parser->parse('config/database.yml');
// 变量会被替换
echo $config->get('database.host'); // localhost