定制 jenner/config 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jenner/config

最新稳定版本:0.5.0

Composer 安装命令:

composer require jenner/config

包简介

PHP configurations loading

README 文档

README

Build Status Latest Stable Version Total Downloads License

PHP configurations loading library. It is made to enable your application to have different configurations depending on the environment it is running in. For example, your application can have different configurations for unit tests, development, staging and production. A good practice would be to not include your production or staging configurations in your version control. To do this, simply add a .gitignore file to your configs/environment directory with the following lines:

*
!.gitignore

Requirements

This library uses PHP 5.3+.

Installation

It is recommended that you install the Config library through composer. To do so, add the following lines to your composer.json file.

{
    "require": {
       "sinergi/config": "dev-master"
    }
}

Usage

Setup the configurations directory:

use Sinergi\Config\Config;

$config = new Config(__DIR__ . "/configs");

Optionally, you can also setup the environment. Setting up the environment will merge normal configurations with configurations in the environment directory. For example, if you setup the environment to be prod, the configurations from the directory configs/prod/* will be loaded on top of the configurations from the directory configs/*. Consider the following example:

$config->setEnvironment('prod');

You can than use the configurations like this:

$config->get('app.timezone');

Getter

The configuration getter uses a simple syntax: file_name.array_key.

For example:

$config->get('app.timezone');

You can optionally set a default value like this:

$config->get('app.timezone', "America/New_York");

You can use the getter to access multidimensional arrays in your configurations:

$config->get('database.connections.default.host');

Setter

Alternatively, you can set configurations from your application code:

$config->set('app.timezone', "Europe/Berlin");

You can set entire arrays of configurations:

$config->set('database', [
    'host' => "localhost",
    'dbname' => "my_database",
    'user' => "my_user",
    'password' => "my_password"
]);

Examples

See more examples in the examples folder.

Example of a configuration file:

return [
    'timezone' => "America/New_York"
];

统计信息

  • 总下载量: 38
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-05-09