2017 © Pedro Peláez
 

library setting

Persistent configuration settings for Laravel - Create, Read, Update and Delete settings stored in files using JSON

image

minkbear/setting

Persistent configuration settings for Laravel - Create, Read, Update and Delete settings stored in files using JSON

  • Tuesday, August 4, 2015
  • by minkbear
  • Repository
  • 1 Watchers
  • 2 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

Laravel Setting (Laravel 5 package)

Persistent configuration settings for Laravel - Create, Read, Update and Delete settings stored in files using JSON., (*2)

This package was the result of me not being able to save new settings to config files in a more persistent way., (*3)

This package was designed not to replace the config solution currently offered by Laravel but rather complement it and be used in unison with it., (*4)

By default the data is stored in storage_path().'/app/setting.json' but this can be easily changed either in the config file or on the fly in realtime., (*5)

This package also provides a fallback for the Laravel Config facade, you can set it in the config, if the key is not found in the json file it will look it up in the Config facade., (*6)

Contributors

janhartigan (Treeface)
Nils Plaschke (Chumper)

Installation

Require this package in your composer.json:, (*7)

"philf/setting": "dev-master"

And add the ServiceProvider to the providers array in app/config/app.php, (*8)

'minkbear\Setting\SettingServiceProvider',

And publish the config file, (*9)

php artisan vendor:publish --provider="minkbear\Setting\SettingServiceProvider"

Usage

Config

return array(
'path'     => storage_path().'/app',
'filename' => 'setting.json',
'fallback' => true,
'autoAlias => true,
);

Fallback capability built in.

// Automatic fallback to Laravel config
Setting::get('app.locale');

Single dimension

set:        Setting::set('name', 'Phil')
get:        Setting::get('name')
forget:     Setting::forget('name')
has:        Setting::has('name')

Multi dimensional

set:        Setting::set('names.firstName', 'Phil')
set:        Setting::set('names.surname', 'F')
    or
set:        Setting::set('names', array('firstName' => 'Phil', 'surname' => 'F'))
setArray:   Setting::setArray(array('firstName' => 'Phil', 'surname' => 'F'))
get:        Setting::get('names.firstName')
forget:     Setting::forget('names.surname'))
has:        Setting::has('names.firstName')

Array processing

    // Get all of the entries in the names array
    $names = Setting::get('names');        
    foreach ($names as $key => $val)
    {
        ...
    }

    // Get the whole array
    $everything = Setting::get();

You can also clear the JSON file with the clear command, (*10)

clear:      Setting::clear()

Using a different path (make sure the path exists and is writable) *, (*11)

Setting::path(app_path().'/storage/meta/sub')->set('names2', array('firstName' => 'Phil', 'surname' => 'F'));

Using a different filename, (*12)

Setting::filename('setting2.json')->set('names2', array('firstName' => 'Phil', 'surname' => 'F'));

Using both a different path and filename (make sure the path exists and is writable), (*13)

Setting::path(app_path().'/storage/meta/sub')->filename('dummy.json')->set('names2', array('firstName' => 'Phil', 'surname' => 'F'));

License

Laravel Setting is open-sourced software licensed under the MIT license, (*14)

The Versions

04/08 2015

dev-master

9999999-dev

Persistent configuration settings for Laravel - Create, Read, Update and Delete settings stored in files using JSON

  Sources   Download

MIT

The Requires

 

The Development Requires

by Phil Foulston

laravel config

04/08 2015

1.2.0

1.2.0.0

Persistent configuration settings for Laravel - Create, Read, Update and Delete settings stored in files using JSON

  Sources   Download

MIT

The Requires

 

The Development Requires

by Phil Foulston

laravel config

14/05 2015

1.1.0

1.1.0.0

Persistent configuration settings for Laravel - Create, Read, Update and Delete settings stored in files using JSON

  Sources   Download

MIT

The Requires

 

The Development Requires

by Phil Foulston

laravel config