Download the PHP package hiddencorporation/laravel-db-config without Composer
On this page you can find all versions of the php package hiddencorporation/laravel-db-config. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hiddencorporation/laravel-db-config
More information about hiddencorporation/laravel-db-config
Files in hiddencorporation/laravel-db-config
Package laravel-db-config
Short Description :A package for laravel to handle configuration data set
License MIT
Homepage https://github.com/hiddenCorporation/laravel-db-config
Informations about the package laravel-db-config
laravel-db-config
A package to manage configuration items and their properties in Laravel. php laravel configuration cache db
What it is
Another library to handle configuration data in laravel, much more an exercice to handle gitHub/Packagist sync. This library.
In addition to allowing you to simply save variables in database, this package allows you to:
-
Add a description to these variables.
-
Standardize the caching of those variables (setting up indexes, updating the cache time, updating the cached config var).
-
On-the-fly encryption / decryption of values.
- Automatically retrieving multiple configuration values.
Installation
Using GitHub
git clone https://github.com/hiddenCorporation/laravel-db-config.git
Using Laravel Packager
Using Laravel Packager https://github.com/Jeroen-G/laravel-packager
. You can use artisan to integrate it in your laravel app.
https://github.com/Jeroen-G/laravel-packager
Using Composer
Configuration
After having install the package, you need to :
Publish configuration var for the package
Migrate database layout
Configuration file & env
(optional) change behaviour of package
To set in your .env :
-
DBCONFIG_USECACHE use cache or not.
-
DBCONFIG_PREFIXCACHE & DBCONFIG_PREFIXCACHE_INTERNAL mostly use to avoid collision using a prefix to define perimeter.
- auto cache management experimental -
If cache enabled, you can add cache_management option when setting a config. cache_management can be fix or auto. (fix is the default value).
Auto mode is still in evaluation.
- fix : use only cache_duration
- auto :
If cache_duration is filled, system will register in cache your config with this time. If not this field will take value of cache_duration_default.
-
DBCONFIG_CACHE_AUTO_GET Activate get process to improve cache_duration.
-
DBCONFIG_CACHE_AUTO_MODIFY Activate modify process to improve cache_duration.
-
DBCONFIG_CACHE_DURATION_MIN In seconds, the minimum amount of time for auto Cached var.
-
DBCONFIG_CACHE_DURATION_MAX In seconds, the maximum amount of time for auto Cached var.
-
DBCONFIG_CACHE_DURATION_DEFAULT In seconds, the amount of time by default for auto Cached var.
-
DBCONFIG_CACHE_SSM_FLOOR Between 1 and 0 think of it as a ratio : I want 20% of the modification for the same var happening when not cached, my ratio will be 0.8.
-
DBCONFIG_CACHE_TSM_FLOOR Number of Modification used to recalculate cache_duration think of it like a dataset of ssm.
-
DBCONFIG_CACHE_SSG_FLOOR Between 1 and 0 think of it as a ratio : I want 20% of the get for the same var happening when not cached, my ratio will be 0.8.
- DBCONFIG_CACHE_TSG_FLOOR Number of get request used to recalculate cache_duration think of it like a dataset of ssg.
cache_ssg_floor and cache_tsg_floor are used to decrease cache_duration of a var.
- DBCONFIG_CACHE_CALCULUS_PRECISION Between 0 and 1. To avoid an eternal fight between modification and get we can fix an additionnal ratio : For example for a ccp of 0.02 :
with the ssm of 0.8 the score calculus of a modification has to be between 0.078 and 0.082 to be considered good same for the get Operation
Methods
- dbConfig::set($name,$value,$additionalAttribute=array())
- $name the name of the var will be slugify to forge a technical_name.
- $value can be all kind of var
- $additionalAttribute description (string) cache_duration (int), Seconds use for fix cache or to set a duration to begin when in auto. _ cache_management fix or auto by default fixed. _ crypted (bool)
return An array with operation status and the element if created, if not list of errors.
- dbConfig::get($entity=false,$defaultReturnValue = Null,$full=false)
- $entity the config id, the technical Name of a config element or a mixed array of both.
- $defaultReturnValue (defaut = Null) The default return value you want.
- $full if true will return all info about the configuration var
It can return null if data not found, an array of var if entity is an array,a single value or the value with all info if full = true.
- dbConfig::update($entity=false,$value=Null,$additionalAttribute=array())
- $entity $entity_id or technical_name
- $value (default Null), the new value or nothing if you just want to manage additional attributes.
- $additionalAttribute see dbConfig::set
Return An array with the detail of the operation and the configuration element if found.
- dbConfig::unset($entity)
- $entity entity id or technical_name
- $infoSup (default false) To get more intel about where the config has been found.
Return cache, db or true/false depends if $infoSup is true
Return Null, true or false
- dbConfig::configExist($entity,$infoSup=false)
Commands
The clear cache specifically target elements used by dbConfig leaving other cached things intacts
The test has been done for basic use, auto cache management has not been tested at the moment.
Unit test
The testUnits replicate test of dbConfig:test
Roadmap
- test auto mode
- create unit test for benchmarking the package for the auto Cache Management