slexx / config
PHP配置管理器
v1.0.2
2018-05-10 12:28 UTC
Requires
- noczcore/ini: ^1.1
- symfony/yaml: ^3.3
Requires (Dev)
- phpunit/phpunit: ^6.2
This package is auto-updated.
Last update: 2024-09-08 06:43:37 UTC
README
安装
通过composer
安装
$ composer require slexx/config
文档
Config->__construct([$file])
参数
示例
new Config('config.json'); new Config('config.ini'); new Config(); new Config(['foo' => 'bar']);
Config->setFile($file)
设置文件路径
参数
返回: $this
Config->getFile()
获取文件路径
返回: null
, string
Config->save()
保存配置
返回: $this
示例
$config = new Config('config.json') $config->set('foo', 'bar'); $config->save();
Config->toArray()
转换为数组
返回: array
Config->all()
返回: array
Config->count()
返回: int
Config->getIterator()
返回: \ArrayIterator
Config->set($key, $value)
设置配置变量
参数
返回: $this
Config->has($key)
检查配置变量是否存在
参数
返回: bool
Config->get($key)
获取配置变量的值
参数
返回: mixed
, null
- 变量的值或不存在时返回null
Config->remove($key)
删除配置变量
参数
返回: $this