vi-kon/laravel-db-config

This package is abandoned and no longer maintained. No replacement package was suggested.

Laravel 5 database configurator

v1.2.0 2016-05-09 22:43 UTC

This package is not auto-updated.

Last update: 2021-03-05 21:49:31 UTC


README

This is Laravel 5 package for storing dynamic config in database.

Table of content

Back to top

Features

  • Dynamic config stored in database
  • Easily add new keys

Back to top

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.

Back to top

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');

Back to top

License

This package is licensed under the MIT License

Back to top