weboap / option
该软件包已被废弃且不再维护。未建议替代软件包。
从数据库保存和检索配置,用于laravel 5 / 将配置作为数组访问
v2.0.4
2019-02-10 07:33 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- illuminate/cache: 5.*
- illuminate/config: 5.*
- illuminate/support: 5.*
- mockery/mockery: dev-master
README
从数据库保存和检索配置,用于laravel / 将配置作为数组访问
laravel 4用户使用 "weboap/option": "v1.0.5"
安装
推荐通过composer安装Winput。
步骤 1
php composer require weboap/option
步骤 2(可选)
如果使用laravel <5.5,请添加config/app.php
'Weboap\Option\OptionServiceProvider'
步骤 3
运行迁移Option表
php artisan vendor:publish php artisan migrate
您可以在app/option.php中自定义Option配置文件。
使用方法
注意:键应设置为group.key(例如:'gallery.path', 'cache.timeout'),这样选项将按分类键分组。如果没有分组,该软件包将在前面添加'global.',例如:设置键:'business'将被检索为'global.business'
//set one key Option::set('group.key', 'value'); // or set an array of key, values Option::set(['key0'=> 'value', 'group.key'=>'value', 'someothergroup.key1'=>'value1', .....]); Option::get('group.key'); Option::get('global.key'); Option::group('prefix'); // will return an array of options prefixed with group Option::forget('group.key'); Option::has('group.key'); //retreive all keys, values at once Option::all(); or you can access config as array like $config = App::make('option'); $config['mygroup.foo'] = 'bar'; echo $config['mygroup.foo']; unset($config['mygroup.foo']);
享受!