Laravel 5: Configuration: database based configuration

Laravel 5: Configuration: database based configuration

Laravel offers great, file based configuration, but it is cumbersome to adjust from GUI.

GUI friendly database based configuration.
Database tables
I use 3 tables to accomplish database based config.
  1. configurations
    This table holds main configuration key/value pairs, plus some extra stuff.
  2. configuration_groups
    This table is just in case, if you get to have a lot of configuration data and want to group them in some GUI.
  3. configurables
    If you have many user types, with different access levels, you may use this to link particular configuration key/value to user. Since this is a poly-pivot table, you can easily clone multiple groups at any time of your app development. Of course this is meant for GUI use, if you want to allow editing of db based config values.
Migration Files



Language Files

Columns: ‘name’, ‘description’ do not hold actual names, or description, but location to language localized translations.

Here are my language files.




If you group your files in subfolders, dot notation would not work. You have to use slashes, e.g.:

Service Provider code

I used existing service provider: AppServiceProvider, to fire my database based config values.
See method: dbConfig();

I am using cache, to make it speedy.
My cache never expires.
Reason for this forever cache is that I want it to hold, until it is changed, e.g. from GUI.
It will be (should be) overwritten, when anything is changed va GUI.

How to Use It

You use it as you’d use standard config stuff.

I added ‘db.‘ prefix, to make it clearly visible in code, where it comes from.
No need to add it to db config key.

That is all.