eig/configurator
最新稳定版本:2.1.0
Composer 安装命令:
composer require eig/configurator
包简介
A PHP Generic Configuration Object
README 文档
README
A Configuration Loader for PHP Packages
This package is a standalone library to allow you to have easy setup and access to configuration variables in your own php packages.
Supports
PHP
- 7.2
- 7.3
Install
composer require eig/configurator
Usage
Include the Configurator class in your application:
use eig\Configurator\Configurator as Config;
Now call instantiate a copy:
$config = new Config("path/to/files");
or load in an array of values
$config = new Config($array, $key);
You can mix and match methods of loading config values.
Now you can reference your configuration variable loaded from the files supplied with dot notation on the config object:
$config->get('app.name');
You also have access to several methods:
all() -> returns all items
get($key) -> returns the item at the key, may be dot notation
has($key) -> returns boolean (True/False) if the value exists, may use dot notation
load($value, $key) -> load more values into the config object, **Note: $key is only required for adding an array of values. For adding files the file name is used as the top level key.
Facade
To use the library through a Facade use eig\Configurator\Facades\Configurator
Then in your code you can load and access your configuration values like so:
/** * This mehtod is required first to access any configuration values * Failing to load first will return a null to any calls to items() or get() */ Configurator::load($path); /** * This method will return all items that are loaded as an array. */ Configurator::all(); /** * This method will return the item you specify just like using the array notation on a * regular Configurator instance */ Configurator::get($value); /** * This method will return true or false if the value exists in the config object */ Configurator::has($value); /** * This method sets the value provided to the key */ Configurator::set($key, $value)
Contributing
To contribute to this project clone the github repository create a new branch with the feature you are creating or bug you are fixing. Write tests to prove your feature or bugfix works then submit a pull request on github.
Roadmap
统计信息
- 总下载量: 523
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-08-26