Download the PHP package cryental/laravel-dynamic-config without Composer
On this page you can find all versions of the php package cryental/laravel-dynamic-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cryental/laravel-dynamic-config
More information about cryental/laravel-dynamic-config
Files in cryental/laravel-dynamic-config
Package laravel-dynamic-config
Short Description This Package makes it possible for users to have their config files stored in a database table, making it easier to customize these values from UI.
License MIT
Informations about the package laravel-dynamic-config
Larvel Dynamic Config
Introduction
This Package makes it possible for users to have their config files stored in a database table, making it easier to customize these values from UI.
Installation
You can install the package via composer:
The package will automatically register itself.
You can publish the config with:
Config file:
Migration:
Usage
First of all, you need to decide which config file(s) you want them to be stored in database by adding 'dynamic'=> true
to the file, as simple as that:
- Note that
dynamic
indicator is defined in/config/emadha/dynamic-conf.php
:- You can add
dynamic=>true
to any config file to store it in database and fetch the values from there instead of using the actual config file- The values defaults will be taken from the actual config file.
- You can have more than one config file loaded dynamically
dynamic=>true
can only be added in the first dimension of that config array.
The main config file of this packages is located in /config/emadha/dynamic-conf.php
and contains the following code:
The content of that file is pretty clear and well documented.
Usage
As simple as that.
Why is that Useful?
In case you ever wanted to control the site title from a UI (backend, frontend), in a dynamic way without having to edit the actual config file, then this a good approach.
Another Example: Let's say you have a google analytics code a long with some other customizations, and you have these in /config/site.php
as follows:
This config file cannot be easily modified from a user interface, thus your clients will not be able to edit this without editing the actual file,
In that case this package will prove to be useful, adding the key dynamic
=>true to that config file will make it store it's values in database using the same format as Laravel, therefore it will be no different for you to get the value of some key in that config file, example config('site.google.UA)
, plus adding some nice features like updating the value and revert back to default.
With that approach you can now create a backend input to customize these, using one line of code config('site.google.UA')->setTo('XYZ');
and then use it in your blade like normal: