niletphp/configuration

NiletPHP 配置组件。

v1.0.0 2017-03-02 09:10 UTC

This package is not auto-updated.

Last update: 2024-09-29 02:40:30 UTC


README

使处理PHP配置数组变得轻松。

需求

PHP >= 7.0

安装

Composer

{
    "require": {
        "niletphp/configuration": ">=v1.0"
    }
}

示例

$config = new Nilet\Components\Configuration\Config();

设置配置文件夹

$configDir = new Nilet\Components\FileSystem\Directory("path/to/config/files");
$config->setConfigDir($configDir);

获取配置文件夹

$configDir = $config->getConfigDir();

从给定的配置文件检索配置数组

/** 
* Lets assume that there is a config file called foo.php inside the config directory
* with the following array 
* [
*   "bar" => true,
*   "baz" => false
* ]
*/
$foo = $config->get("foo");
$foo["bar"];
$foo["baz"];