vi-kon/laravel-db-config
最新稳定版本:v1.2.0
Composer 安装命令:
composer require vi-kon/laravel-db-config
包简介
Laravel 5 database configurator
关键字:
README 文档
README
This is Laravel 5 package for storing dynamic config in database.
Table of content
Features
- Dynamic config stored in database
- Easily add new keys
Installation
Via composer run following command in your project root:
composer require vi-kon/laravel-db-config
In your Laravel 5 project add following lines to app.php:
// to app.php's providers array 'ViKon\DbConfig\DbConfigServiceProvider',
To install database migration file simple call following commands:
php artisan vendor:publish --provider=ViKon\DbConfig\DbConfigServiceProvider php artisan migrate
This will install create_config_table migration file to application database/migrations directory and create new config table in default database.
Usage
Getting values
Getting data from database is simple:
$value = config_db('key');
Provide default value if key not exists in database
$value = config_db('key', 'default_value');
If no parameter provided to config_db function, then it returns ViKon\DbConfig\DbConfig instance.
// Get value by key $value = config_db()->get('key'); // Get value by key with default value $value = config_db()->get('key', 'default_value');
Set values
Set values to database is easy simple call config_db function with no parameter and after it call set method.
config_db()->set('key', 'value');
###Organize config keys
For better maintenance there is a support organizing config values to groups. To get or set config value to group simple use {group}::{key} schema as key.
// Gets 'db' group username value $value = config_db('db::username');
License
This package is licensed under the MIT License
统计信息
- 总下载量: 864
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 7
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-11-09