sigjlr/phpconfig
Composer 安装命令:
composer require sigjlr/phpconfig
包简介
Load INI configuration files
关键字:
README 文档
README
A simple reader of .ini configuration files.
##Install You may install the phpConfig with Composer (recommended) or manually.
##Usage This example assumes you are autoloading dependencies using Composer or any other PSR-0 compliant autoloader.
//Create a new PhpConfig $config = new \PhpConfig\PhpConfig(); //Add any ini resources $config->addResource('config.ini'); //You can add many resource in a single line $config->addResource('config.ini', 'config2.ini' ); //Load the resources and produce the configuration array //If the same key is present in many resources, the last one will be preserved. $config->load(); //Get the configuration array $myConfiguration = $config->getConfig();
To deny browser access to the .ini files add this directive in .htaccess
<Files *.ini>
Order deny,allow
Deny from all
</Files>
By example consider this ini files:
Global.ini:
[Section_A] param1 = GlobalA1 param2 = GlobalA2
Local.ini:
[Section_A] param1 = LocalA1 param3 = LocalA3 [Section_B] param1 = LocalB1 param2 = LocalB2
With this code:
//Create a new PhpConfig $config = new \PhpConfig\PhpConfig(); //Add resources $config->addResource('Global.ini', 'Local.ini' ); $config->load(); $myConfiguration = $config->getConfig(); print_r($myConfiguration); /* you get this array: Array( [Section_A]=>array( [param1] => LocalA1, [param2]=> globalA2, [param3]=> LocalA3 ), [Section_B]=>array( [param1] => LocalB1, [param2]=> LocalA2 ) ) */
##License The phpConfig is released under the MIT public license
统计信息
- 总下载量: 19
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-09-24