koshatul/config
最新稳定版本:v1.2.1
Composer 安装命令:
composer require koshatul/config
包简介
Koshatul Config Class
README 文档
README
A Configuration class for PHP for keeping configuration items separate from repositories or incorporating config into repositories.
Installation
Use Composer to install the package:
Add the following to your composer.json and run composer update.
"require": { "koshatul/config": "~1.0" }
Example
Example configuration file (could be in project root (in the repository), above that or in the users home directory)
[testsection] test="testdatavalue" [anothersection] test="differentvalue" [uritest] mysqlurl="mysql://username:password@hostname:1234/schema"
Usage
You can use this package to get configuration from a global or specific configuration store.
It will pull values from the specified file first, and fallback to environment variables.
Config::Get('project/apikey')
would look in the file first for
[project] apikey="value"
and fallback to the environment variable
PROJECT_APIKEY="value"
use Koshatul\Config\Config; $value = Config::Get('project/apikey'); print_r($value); $array = array( 'driver' => 'pdo_mysql', 'host' => Config::GetMySQLURI('project/db', PHP_URL_HOST), 'dbname' => Config::GetMySQLURI('project/db', PHP_URL_PATH), 'user' => Config::GetMySQLURI('project/db', PHP_URL_USER), 'password' => Config::GetMySQLURI('project/db', PHP_URL_PASS), 'port' => $port, ); print_r($array);
统计信息
- 总下载量: 128
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-10-02