Easy implementable package to handle application settings for different scopes with flexible storage places
A nice little package to set and get settings on different scopes. In the current state, you can define settings for a eloquent model (which defines the scope) and general settings (which are always in always in the global scope). There are, or at least will be, different drivers, so your settings can be stored everywhere you want. Yay!, (*1)
composer require swavel/settisizer
Holy shit, that was easy! Now let's go, (*2)
The only thing you have to do to use the settisizer in a model (besides to include it in your composer dependencies) is to use the trait in the class like this:, (*3)
<?php namespace Your\Awesome\Proiject class Fu extends Model { use Settisizable; [...]
with that given, you just can use it in every instance of that class:, (*4)
$u = User::find(42); $u->setSetting([settingname], [settingvalue]); [...] $u->getSetting([settingname]);
should there be no value stored for the requested setting, don't you worry child, we cover you there! No errors, just a sober null which will be returned. Yay again!, (*5)
In the status quo, one have to have a instance of a concretion of a Settisizer Class, which is, at the moment, always is one of the SettisizerStorage class., (*6)
$settisizer = new SettisizerStorage(); $settisizer->setSetting([globalsettingname], [settingvalue]); [...] $settisizer->getSetting([globalsettingname]);
To manage your own config. Run this command., (*7)
php artisan vendor:publish --provider=Settisizer\SettisizerServiceProvider
Run phpUnit tests with ../../../vendor/bin/phpunit, (*8)
<?php Settisizer::getSetting('setting_name')
27.03.2018 - Write a second driver (mysql, redis), (*9)
27.03.2018 - Integrate publish function to write standard config file (to select different drivers), (*10)