fuelphp/config 问题修复 & 功能扩展

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

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

fuelphp/config

Composer 安装命令:

composer require fuelphp/config

包简介

Fuel package for loading, saving and accessing config settings

README 文档

README

Build Status Code Coverage Quality Score

Fuel package for loading, saving and accessing config settings.

There are multiple formats in which config files can be handled:

  • php
  • json
  • yaml
  • ini

The only odd one is ini. It's the only filetype that can't be automatically formatted for saving. Symfony\Yaml is needed in order to parse and format .yml files.

Loading

Get a new container

use Fuel\Config\Container;

$config = new Container;

We'll need to add a path to load the files from:

$config->addPath(__DIR__.'app/config');

Now we're able to load config files.

$config->load('name');
// Load app/config/name.php into the name group


$other = $config->load('other', false);
// load it, but don't store it

$config->load('data.json');
// Load json data

Default format

It's also possible to set a default config format. By default this is php.

$config->setDefaultFormat('json');

$data = $config->load('data');
// this will load data.json

Environment settings

An environment will be used to load a secondary config file and will overwrite the default settings.

$config->setEnvironment('develop');

Saving

It's possible to write all the types (except for ini) to disk.

$container->save('data');

// or use an alternate location
$container->save('data', 'other/file');

The container is aware of overwrites so it'll always save the config file in the place last loaded, therefor overwriting all that came before.

Accessing data

The config Container extends the FuelPHP\Common\DataContainer class. Therefor it's possible to retrieve the data in two ways: through ->get and the ArrayAccess way.

$setting = $config->get('setting');

// is the same as

$setting = $config['setting'];

The first way does allow you to supply a default

Contributing

Thank you for considering contribution to FuelPHP framework. Please see CONTRIBUTING for details.

License

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

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 5
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-01-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固