crcms/file-config

文件配置的存取

0.0.7 2018-04-26 05:30 UTC

This package is auto-updated.

Last update: 2024-08-29 03:42:09 UTC


README

设置配置文件的存储格式

示例

更新file_config.php

'files'=>[
    /tmp/crcms,
    // Set up other parsing drivers
    /tmp/crcms => \CrCms\FileConfig\Drives\SerializeConfig::class,
    
],

'default_drive'=>\CrCms\FileConfig\Drives\DefaultConfig::class,

存入

file_config([
    crcms.a=>'a',
    crcms.b=>'b'
])

//or

file_config()->put('crcms.a',['k'=>'k','s'=>'s'])

获取

file_config('crcms.a')

全部

file_config('crcms')

销毁

file_config()->destroy('crcms.a')

0.0.2以上版本支持新的加载方法

Example test.php
key1=>value1
key2=>value2

//get all
file_config()->load('/path/test.conf')->all('test')

0.0.3 增加多层点深度支持

file_config()->load('/path/test.conf')->get('test.depth1.depth2.0')

0.0.4 覆盖所有配置

file_config(['crcms'=>[1,2,3]])

//or

file_config()->put('crcms',['key'=>[1,'value']])

安装

您可以通过composer安装此包

composer require crcms/file-config

Laravel

修改config / app.php

'providers' => [
    CrCms\FileConfig\FileConfigServiceProvider::class,
]


'aliases' => [
    'FileConfig' => \CrCms\FileConfig\Facades\FileConfig::class
],

如果您想在配置文件中进行配置更改,可以使用以下Artisan命令发布

php artisan vendor:publish --provider="CrCms\FileConfig\FileConfigServiceProvider"

Laravel测试

phpunit ./tests/Config

许可协议

MIT