Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unisharp/laravel-settings
Persistent key-value storage for Laravel, json value supported. l10n supported.
https://github.com/unisharp/laravel-settings
config key-value laravel locale setting
Last synced: 3 days ago
JSON representation
Persistent key-value storage for Laravel, json value supported. l10n supported.
- Host: GitHub
- URL: https://github.com/unisharp/laravel-settings
- Owner: UniSharp
- License: mit
- Created: 2015-07-29T07:31:23.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-10-05T09:44:13.000Z (over 5 years ago)
- Last Synced: 2024-12-30T13:37:39.609Z (10 days ago)
- Topics: config, key-value, laravel, locale, setting
- Language: PHP
- Homepage:
- Size: 48.8 KB
- Stars: 106
- Watchers: 10
- Forks: 26
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Latest Version on Packagist][ico-version]][link-packagist]
[![Software License][ico-license]](LICENSE.md)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
[![Total Downloads][ico-downloads]][link-downloads]# Persistent Settings Manager for Laravel
* Simple key-value storage
* Support multi-level array (dot delimited keys) structure.
* Localization supported.## Installation
1. Install package
```bash
composer require unisharp/laravel-settings
```1. Edit config/app.php (Skip this step if you are using laravel 5.5+)
service provider:
```php
Unisharp\Setting\SettingServiceProvider::class,
```class aliases:
```php
'Setting' => Unisharp\Setting\SettingFacade::class,
```1. Create settings table
```bash
php artisan vendor:publish --tag=settings
php artisan migrate
```## Usage
```php
Setting::get('name', 'Computer');
// get setting value with key 'name'
// return 'Computer' if the key does not existsSetting::all();
// get all settingsSetting::lang('zh-TW')->get('name', 'Computer');
// get setting value with key and languageSetting::set('name', 'Computer');
// set setting value by keySetting::lang('zh-TW')->set('name', 'Computer');
// set setting value by key and languageSetting::has('name');
// check the key exists, return booleanSetting::lang('zh-TW')->has('name');
// check the key exists by language, return booleanSetting::forget('name');
// delete the setting by keySetting::lang('zh-TW')->forget('name');
// delete the setting by key and language
```## Dealing with array
```php
Setting::get('item');
// return null;Setting::set('item', ['USB' => '8G', 'RAM' => '4G']);
Setting::get('item');
// return array(
// 'USB' => '8G',
// 'RAM' => '4G',
// );Setting::get('item.USB');
// return '8G';
```## Dealing with locale
By default language parameter are being resets every set or get calls. You could disable that and set your own long term language parameter forever using any route service provider or other method.
```php
Setting::lang(App::getLocale())->langResetting(false);
```[ico-version]: https://img.shields.io/packagist/v/UniSharp/categorizable.svg?style=flat-square
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/UniSharp/categorizable/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/UniSharp/categorizable.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/UniSharp/categorizable.svg?style=flat-square
[ico-downloads]: https://img.shields.io/packagist/dt/UniSharp/categorizable.svg?style=flat-square[link-packagist]: https://packagist.org/packages/unisharp/categorizable
[link-travis]: https://travis-ci.org/UniSharp/categorizable
[link-scrutinizer]: https://scrutinizer-ci.com/g/UniSharp/categorizable/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/UniSharp/categorizable
[link-downloads]: https://packagist.org/packages/UniSharp/categorizable
[link-author]: https://github.com/UniSharp
[link-contributors]: ../../contributors