2017 © Pedro Peláez
 

library settings

Persistent settings package for Laravel framework.

image

fei77/settings

Persistent settings package for Laravel framework.

  • Sunday, April 22, 2018
  • by Fei77
  • Repository
  • 0 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 19 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Persistent Settings for Laravel 5

Build Status, (*1)


Persistent settings package for Laravel 5., (*2)


  • Driver support
  • Cache settings via laravel cache
  • Encrypt / Decrypt setting values
  • Fire events after action
  • Override config values
  • Helper function
  • Settings by context
  • Serialize values

Installation

composer require fei77/settings

Version matrix

Laravel Version Package version
>=5.0, <=5.1 >= 1.0.0, <= 2.0.0
5.2 >= 2.0.0
>=5.5 >= 3.0.0

Registering to use it with laravel

laravel 5.5 will discover the package automatically so you can skip this step if using laravel 5.5, (*3)

Add following lines to app/config/app.php, (*4)

ServiceProvider array, (*5)

Krucas\Settings\Providers\SettingsServiceProvider::class,

Alias array, (*6)

'Settings' => Krucas\Settings\Facades\Settings::class

Publishing config file

If you want to edit default config file, just publish it to your app folder., (*7)

php artisan vendor:publish --tag="settings"

Usage

Configuration

Package comes with several configuration options., (*8)

Setting Description
default Setting repository driver.
cache Enable or disable setting cache.
encryption Enable or disable setting value encryption.
events Enable or disable event firing.
repositories Config of all repositories which can be used.
key_generator Key generator class.
context_serializer Context serializer class.
value_serializer Value serializer class.
override Allows you to override values in Laravel config array.

Creating table for database driver

To use database driver you have to create table in your database. Package provides default table migration, to create it you need to execute artisan command:, (*9)

$ php artisan settings:table

Methods

Set value

Set setting value., (*10)

Settings::set($key, $value = null);

Get value

Get setting value, default value is returned when no value found., (*11)

Settings::get($key, $default = null);

Check value

Determine if setting exists., (*12)

Settings::has($key);

Forget value

Forget setting value from repository., (*13)

Settings::forget($key);

Set context

Setting values may be used in certain context. Context can be set using method context()., (*14)

Settings::context(new Context(['user' => 1]));

Context is reset after call of one these methods set, get, has, forget. Example how to use settings for different contexts., (*15)

$userContext1 = new Context(['user' => 1]);
$userContext2 = new Context(['user' => 2]);
Settings::context($userContext1)->set('key', 'value1');
Settings::context($userContext2)->set('key', 'value2');

// retrieve settings
$userValue1 = Settings::context($userContext1)->get('key'); // value1
$userValue2 = Settings::context($userContext2)->get('key'); // value2

Helpers

Settings service instance

Resolve settings service instance., (*16)

settings();

Set value

Set setting value., (*17)

settings([$key => $value]);

Set setting value for a context., (*18)

settings([$key => $value], new Context(['user' => 1]));

Get value

Get setting value, default value is returned when no value found., (*19)

settings($key, $default = null);

Getting value for a context., (*20)

settings($key, $default, new Context(['user' => 1]));

Events

Events gets fired if this is not disabled via config (enabled by default)., (*21)

settings.checking: $key

Fired before checking if value is present in repository., (*22)

Parameter Type Parameter description
$key string Setting key.
$context null or Context Setting context.

settings.has: $key

Fired after checking if value is present in repository., (*23)

Parameter Type Parameter description
$key string Setting key.
$status bool If setting exists true is passed, otherwise false
$context null or Context Setting context.

settings.getting: $key

Fired before retrieving value from repository., (*24)

Parameter Type Parameter description
$key string Setting key.
$default mixed Default setting value.
$context null or Context Setting context.

settings.get: $key

Fired after retrieving value from repository., (*25)

Parameter Type Parameter description
$key string Setting key.
$value mixed Retrieved setting value.
$default mixed Default setting value.
$context null or Context Setting context.

settings.setting: $key

Fired before setting value to repository., (*26)

Parameter Type Parameter description
$key string Setting key.
$value mixed Setting value to be set.
$context null or Context Setting context.

settings.set: $key

Fired after setting value to repository., (*27)

Parameter Type Parameter description
$key string Setting key.
$value mixed Setting value to be set.
$context null or Context Setting context.

settings.forgetting: $key

Fired before forgetting value., (*28)

Parameter Type Parameter description
$key string Setting key.
$context null or Context Setting context.

settings.forget: $key

Fired after forgetting value., (*29)

Parameter Type Parameter description
$key string Setting key.
$context null or Context Setting context.

The Versions

22/04 2018

dev-master

9999999-dev

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings

21/04 2018

3.0.0

3.0.0.0

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings

19/01 2016

2.0.0

2.0.0.0

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings

19/01 2016

dev-dev

dev-dev

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings

19/01 2016

1.2.0

1.2.0.0

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings

18/10 2015

1.1.0

1.1.0.0

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings

29/06 2015

1.0.0

1.0.0.0

Persistent settings package for Laravel framework.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Edvinas Kručas

laravel settings persistent settings