swavel / settisizer
Easy implementable package to handle application settings for different scopes with flexible storage places
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 7
Forks: 0
Open Issues: 0
Type:metpackage
This package is not auto-updated.
Last update: 2024-11-10 05:14:18 UTC
README
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!
Installation
composer require swavel/settisizer
Holy shit, that was easy! Now let's go
Usage
In a model
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:
<?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:
$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!
Globaly
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.
$settisizer = new SettisizerStorage();
$settisizer->setSetting([globalsettingname], [settingvalue]);
[...]
$settisizer->getSetting([globalsettingname]);
To manage your own config. Run this command.
php artisan vendor:publish --provider=Settisizer\SettisizerServiceProvider
Developer hints
Run phpUnit tests with ../../../vendor/bin/phpunit
Roadmap
Next steps
- Comment the whole thing
- Facade to access global Settisizer with
- name the settings-table for driver mysql
<?php
Settisizer::getSetting('setting_name')
In progress
27.03.2018
- Write a second driver (mysql, redis)
Done
27.03.2018
- Integrate publish function to write standard config file (to select different drivers)