yetanother / config
另一个PHP配置工具
dev-master
2013-08-04 21:04 UTC
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2024-09-24 05:05:33 UTC
README
YetAnother Config — 简单的配置文件管理器。
安装
推荐通过 composer 安装
{ "require": { "yetanother/config": "dev-master" } }
单个配置文件
// path/to/config.php return array( 'parameter1' => 'value1', 'parameter2' => 'value2' );
use YetAnother\Config\Config; $config = new Config('path/to/config.php'); echo $config['parameter1']; // value1
配置文件目录
config
┕database.php
┕routing.php
┕security.php
use YetAnother\Config\Config; $config = new Config('path/to/config'); echo $config['database']['host'];
使用变量代替数组
// path/to/config.php $parameter1 = 'value1'; $parameter2 = 'value2';
use YetAnother\Config\Config; $config = new Config('path/to/config.php'); echo $config['parameter1'];
包含其他配置文件
config
┕config.php
┕database.php
┕routing.php
┕security.php
// config.php $database = include(__DIR__.'/database.php'); $routing = include(__DIR__.'/routing.php'); $security = include(__DIR__.'/security.php'); // или $database = $this->import('database'); $routing = $this->import('routing'); $security = $this->import('security'); // или $database = $this->import(__DIR__.'/database.php'); $routing = $this->import(__DIR__.'/routing.php'); $security = $this->import(__DIR__.'/security.php');
use YetAnother\Config\Config; $config = new Config('config/config.php'); echo $config['database']['host'];