2017 © Pedro Peláez
 

library laravel-settings

Persistent, application-wide settings for Laravel 5.

image

vendocrat/laravel-settings

Persistent, application-wide settings for Laravel 5.

  • Saturday, September 5, 2015
  • by AlexanderPoellmann
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,425 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 7 % Grown

The README.md

Latest Stable Version Total Downloads License, (*1)

Laravel Settings

Persistent, application-wide settings for Laravel 5., (*2)

Attention: This package is a work in progress, please use with care and be sure to report any issues!, (*3)

Installation

Require the package from your composer.json file, (*4)

"require": {
    "vendocrat/laravel-settings": "dev-master"
}

and run $ composer update or both in one with $ composer require vendocrat/laravel-settings., (*5)

Next register the service provider and (optional) facade to your config/app.php file, (*6)

'providers' => [
    // Illuminate Providers ...
    // App Providers ...
    vendocrat\Settings\SettingsServiceProvider::class
];
'providers' => [
    // Illuminate Facades ...
    'Setting' => vendocrat\Settings\Facades\Setting::class
];

Configuration

Laravel Settings includes an optional config file. Get started buy publishing it:, (*7)

$ php artisan vendor:publish --provider="vendocrat\Settings\SettingsServiceProvider" --tag="config"

This will create a config/settings.php file where you can set for example which driver you want to use (JSON file, database, ...)., (*8)

Migration

Note: You'll only need to complete this step when using the database driver., (*9)

If you want to store your settings in your database, you'll have to set 'driver' in your config/settings.php file to 'database' and publish the migration like so:, (*10)

$ php artisan vendor:publish --provider="vendocrat\Settings\SettingsServiceProvider" --tag="migrations"

Afterwards you'll have to run the artisan migrate command:, (*11)

$ php artisan migrate

Usage

Get all settings
$settings = \Setting::all();
Check if a setting exists
\Setting::has($key);
Get a setting
$setting = \Setting::get($key);
Add/update a setting
\Setting::set($key, $value);
Delete a setting
\Setting::forget($key);
Delete all settings
\Setting::flush();
Save your updates (set, forget, flush)
\Setting::save();

Example

The following example would store the setting 'bar' with the key 'foo', then update it to 'bars', save it and then die & dump all current settings, which is only one unique 'foo' key-value pair., (*12)

\Setting::set('foo', 'bar');
\Setting::set('foo', 'bars');

\Setting::save();

dd(\Setting::all());

Results in, (*13)

array [
  "foo" => "bars"
]

My Edits

  • restructured folders & files
  • uses Eloquent models for database driver with soft deleting
  • add interface contract
  • removed middleware

To-Dos

  • add Redis support
  • add option to group settings (e.g. config/user/...)
  • add logic to automatically render input forms in the frontend for settings (like a simple App Settings view or so)

License

Licensed under MIT license., (*14)

Author

Handcrafted with love by Alexander Manfred Poellmann for vendocrat in Vienna & Rome., (*15)

Based on Laravel Settings by Andreas Lutro., (*16)

The Versions

05/09 2015

dev-master

9999999-dev https://github.com/AlexanderPoellmann/laravel-settings

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings options

05/09 2015

v0.1.1

0.1.1.0 https://github.com/AlexanderPoellmann/laravel-settings

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings options

30/08 2015

0.1.0

0.1.0.0

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings

29/08 2015

0.0.4

0.0.4.0

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings

29/08 2015

0.0.3

0.0.3.0

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings

29/08 2015

0.0.2

0.0.2.0

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings

29/08 2015

0.0.1

0.0.1.0

Persistent, application-wide settings for Laravel 5.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel settings