petersuhm/configure 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

petersuhm/configure

Composer 安装命令:

composer require petersuhm/configure

包简介

A configuration repository for PHP.

关键字:

README 文档

README

Build Status Total Downloads Latest Stable Version

A configuration repository for PHP projects.

Configure is a configuration repository for PHP projects. If your app depends on some sort of configuration settings, you can use Configure to handle them. It has a simple API and supports for different kinds of configuration file formats.

Install

You can install Configure via Composer:

{
    "require": {
        "petersuhm/configure": "dev-master"
    }
}

Basic usage

Using Configure is as simple as instantiating the ConfigurationRepository class and start adding settings to it:

$di->settings = new \Petersuhm\Configure\ConfigurationRepository();

$di->settings->set('template_path', '../templates');

Now you can start querying the repository:

$di->settings->get('template_path');

// You can also provide a default value to be returned
$di->settings->get('not_set', 'default_value');

Configure also has supports for arrays:

$di->settings->set([
    'lang' => 'da',
    'country' => 'dk'
]);

// Multi dimensional arrays will be flattened using dot notation
$di->settings->set([
    'localization' => [
        'lang' => 'da',
        'country' => 'dk'
    ]
]);
$di->settings->get('localization.lang');
$di->settings->get('localization.country');

Using configuration files

As of now, Configure supports YAML and PHP files.

# config.yml
localization:
    lang: da
    country: dk
app_name: Configure
# config.php
<?php

return array(

    'localization' => array(
        'lang' => 'da',
        'country' => 'dk'
    ),

    'app_name' => 'Configure'
);

In order to load the files, you need to create an instance of the relevant file loader class and provide it to the load() method on the repository:

$loader = new \Petersuhm\Configure\Loader\YamlFileLoader('config.yml');
// or
$loader = new \Petersuhm\Configure\Loader\ArrayFileLoader('config.php');

$di->settings->load($loader);

$di->settings->get('localization.lang');
$di->settings->get('app_name');

Testing

Configure is fully covered by unit tests. All code is written using a behavior driven approach with phpspec.

$ vendor/bin/phpspec run

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固