承接 rcsi/filesystem-config 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

rcsi/filesystem-config

Composer 安装命令:

composer require rcsi/filesystem-config

包简介

General Config Library

README 文档

README

rcsi/filesystem-config is an easy to use configuration tool that uses ini or json files for system configuration

About

This tool provides a simple interface for setting and retrieving configuration variables

Composer

add 'rcsi/filesystem-config' to your composer requirements

License

MIT License - https://opensource.org/licenses/MIT

Documentation

This class will generate a php singleton which all of the variables in a config.ini or config.json file have been loaded.

The code is documented inline, and should be clear with a little reading.

Methods

Config::init() Returns a config singleton

get(string $key, mixed|null $default = null) Returns the value of $key or $default. If no default is provided, returns null

getBool(string $key) Returns a boolean based on the key. The strings 'true' or '1' will return true, all else returns false

getArray(string $key, string $delim = ',') Returns an array split along $delim. If no delimiter is provided, it will default to a ','

setFile(string $file) Sets the file name for config

getDir() Returns the config directory

load() Loads the config file into the singleton

save(string|null $type = null) Saves the singleton to the path/file with appropriate attempts to discover file type if not provided

saveINI() Saves the singleton as an INI file to the path

saveJSON() Saves the singleton as a JSON file to the path

determineFileType() Reads the extension of the file in order to detect it's file type

getKeys() Returns all available keys in the config

set($key, $value) Sets a config variable

addArray($key, $value) Adds a value to an config array

dump() Dumps the config

Wrapper

Filesystem-config contains ConfigWrapper, which will automatically attempt to detect your configuration path and provide a loaded config singleton, Or, if you prefer, you can specifiy the config path to bypass discovery. By default, it looks for a config/ directory at the same level as your vendor/ directory.

Useage

ConfigWrapper::setPath(__DIR__ . "/../config"); // Optional...
$config = ConfigWrapper::init()

Example

Contents of config.ini

[Examples]
stringOne = This is a string
boolOne = 0
boolTwo = 1
boolThree = true
arrayOne = One, Two, Three, Four

Code

$config = ConfigWrapper::init();
$string = $config->get('stringOne');              // Returns 'This is a string'
$string = $config->get('stringTwo');              // Returns null
$string = $config->get('stringTwo', 'default');   // Returns 'default'
$bool   = $config->get('boolOne');                // Returns '0'
$bool   = $config->getBool('boolOne');            // Returns false
$bool   = $config->getBool('boolTwo');            // Returns true
$bool   = $config->getBool('boolThree');          // Returns true
$bool   = $config->getBool('boolFour');           // Returns false
$array  = $config->getArray('arrayOne');          // Returns ['One', 'Two', 'Three', 'Four']

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-12-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固