{"id":19029950,"url":"https://github.com/padosoft/laravel-settings","last_synced_at":"2025-04-23T15:54:35.945Z","repository":{"id":32428939,"uuid":"133363448","full_name":"padosoft/laravel-settings","owner":"padosoft","description":"Persistent settings with caching in Laravel","archived":false,"fork":false,"pushed_at":"2025-04-15T08:44:35.000Z","size":355,"stargazers_count":5,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-15T08:48:46.037Z","etag":null,"topics":["laravel","laravel-package","settings"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/padosoft.png","metadata":{"files":{"readme":"readme.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-14T13:18:24.000Z","updated_at":"2025-04-15T08:44:38.000Z","dependencies_parsed_at":"2023-12-12T14:29:01.012Z","dependency_job_id":"a21141c3-2362-4108-b799-729be55e3763","html_url":"https://github.com/padosoft/laravel-settings","commit_stats":{"total_commits":77,"total_committers":6,"mean_commits":"12.833333333333334","dds":0.6233766233766234,"last_synced_commit":"c8a9261ddea541f68cf957ab8be8def7bcd86b60"},"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/padosoft%2Flaravel-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/padosoft","download_url":"https://codeload.github.com/padosoft/laravel-settings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250467807,"owners_count":21435445,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel","laravel-package","settings"],"created_at":"2024-11-08T21:15:53.868Z","updated_at":"2025-04-23T15:54:35.918Z","avatar_url":"https://github.com/padosoft.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Settings\n\n[![License](https://poser.pugx.org/anlutro/l4-settings/license.svg)](http://opensource.org/licenses/MIT)\n\n[![CircleCI](https://circleci.com/gh/padosoft/laravel-settings.svg?style=shield)](https://circleci.com/gh/padosoft/laravel-settings)\n\nPersistent on database, fast in memory, application-wide settings for Laravel.\n\nPerformance are not invalidated because settings are automatic cached when retrived from database. Da completare docs.\n\n## Requirements\n\n    PHP \u003e= 7.1.3\n    Laravel 5.8.*|6.*|7.*|8.*|9.*|10.* (For Laravel framework 5.6.* or 5.7.* please use v1.*)\n\n## Installation \n    \n1. `composer require padosoft/laravel-settings`\n2. Publish the config and migration files by running `php artisan vendor:publish --provider=\"Padosoft\\Laravel\\Settings\\ServiceProvider\"`.\n3. Run `php artisan migrate`\n \n**Before running the migrations be sure you have in your `AppServiceProviders.php` the following lines:** \n```php\nuse Illuminate\\Support\\Facades\\Schema;\n\npublic function boot()\n{\n    Schema::defaultStringLength(191);\n}\n```\n## Installation - Laravel \u003c 5.5\n\n4. Add `Padosoft\\Laravel\\Settings\\ServiceProvider` to the array of providers in `config/app.php`.\n5. Add `'SettingsManager' =\u003e 'Padosoft\\Laravel\\Settings\\Facade'` to the array of aliases in `config/app.php`.\n\n## Usage\n\nYou can either access the setting store via its facade or inject it by type-hinting towards the abstract class `anlutro\\LaravelSettings\\SettingStore`.\n\n```php\n\u003c?php\nSettingsManager::get('foo', 'default value');\nSettingsManager::get('foo', 'default value',false,true); //Get cast value without validation\nSettingsManager::get('foo', 'default value',false,false); //Get raw value\nSettingsManager::get('foo', 'default value',true,false); //Get validated value without cast\nSettingsManager::set('set', 'value');//valid for current session\nSettingsManager::set('set', 'value','validationRule');//with validation rule valid for current session\nSettingsManager::store();//persist settings value on db\nSettingsManager::setAndStore('set', 'value','validationRule');//persisted on database\n?\u003e\n```\n\nCall `Setting::store()` explicitly to save changes made.\n\nYou could also use the `setting()` helper:\n\n```php\n// Get the store instance\nsettings();\n\n// Get values\nsettings('foo');\nsettings('foo', 'default value',true,false);//Get cast value without validation\nsettingsRaw('foo', 'default value');//Get raw value\nsettingsAsString('foo', 'default value');//Get value as a String Validated\nsettings('foo', 'default value',false,true);//Get raw value\nsettings('foo', 'default value',false,false);//Get validated value without cast\nsettings('foo', 'default value',);\nsettings()-\u003eget('foo');\n\n\n```\n\n\n\n#### Using in other packages\n\nIf you want to use settings manager on other packages you must provide migrations to populate settings table.\nFor Example:\n```php\n\u003c?php\n\nuse Illuminate\\Support\\Facades\\Schema;\nuse Illuminate\\Database\\Schema\\Blueprint;\nuse Illuminate\\Database\\Migrations\\Migration;\nuse Illuminate\\Support\\Facades\\DB;\nclass PopulateSettings extends Migration\n{\n    /**\n     * Run the migrations.\n     *\n     * @return void\n     */\n    public function up()\n    {\n        if (config('padosoft-settings.enabled',false)) {\n            DB::table('settings')-\u003einsert([\n                //LOGIN\n                ['key'=\u003e'login.remember_me', 'value'=\u003e'1','descr'=\u003e'Enable/Disable remeber me feature','config_override'=\u003e'padosoft-users.login.remember-me','validation_rules'=\u003e'boolean','editable'=\u003e1,'load_on_startup'=\u003e0],\n                ['key'=\u003e'login.login_reset_token_lifetime', 'value'=\u003e'30','descr'=\u003e'Number of minutes reset token lasts','config_override'=\u003e'auth.expire','validation_rules'=\u003e'numeric','editable'=\u003e1,'load_on_startup'=\u003e0],                \n            ]);\n        }\n\n    }\n\n    /**\n     * Reverse the migrations.\n     *\n     * @return void\n     */\n    public function down()\n    {\n\n    }\n}\n```\nPlease take care of populate config_override column with config key you want your setting should override\n##Add new type of settings with cast and Validation in Config/config.php\n```php\n/*\n      |--------------------------------------------------------------------------\n      | Larvel Settings Manager\n      |--------------------------------------------------------------------------\n      |\n      | This option controls if the settings manager is enabled.\n      | This option should not be is overwritten here but using settings db table\n      |\n      |\n      |\n      |\n      */\n\n    'enabled' =\u003e true,\n    'encrypted_keys' =\u003e [],\n    'cast' =\u003e [\n        //Example new cast and validation\n        //class = class for cast\n        //method = method for cast\n        //validate = rule for validation\n        'boolean' =\u003e ['class' =\u003e \\Padosoft\\Laravel\\Settings\\CastSettings::class, 'method' =\u003e 'boolean', 'validate' =\u003e 'boolean'],\n        'listPipe' =\u003e ['class' =\u003e \\App\\Casts\\ListPipeCast::class, 'validate' =\u003e 'regex:/(^[0-9|]+$)|(^.{0}$)/'],\n        'booleanString' =\u003e ['class' =\u003e \\App\\Casts\\BooleanString::class,'validate' =\u003e 'regex:/^(true|false)/'],\n        'booleanInt' =\u003e ['class' =\u003e \\App\\Casts\\BooleanInt::class,'validate' =\u003e 'regex:/^(0|1)/'],\n        ],\n\n```\n\n## Events Listening\nEvery time a model is created,updated or deleted an event will be dispatched.\nYou can listen these events with a simple Listener in Laravel\n```php\n    public function subscribe(Dispatcher $events): void\n    {\n        $events-\u003elisten(\\Padosoft\\Laravel\\Settings\\Events\\SettingCreated::class, [SettingsEventSubscriber::class, 'handleSettingCreated']);\n        $events-\u003elisten(\\Padosoft\\Laravel\\Settings\\Events\\SettingUpdated::class, [SettingsEventSubscriber::class, 'handleSettingUpdated']);\n        $events-\u003elisten(\\Padosoft\\Laravel\\Settings\\Events\\SettingDeleted::class, [SettingsEventSubscriber::class, 'handleSettingDeleted']);\n    }\n```\n\n## Contact\n\nOpen an issue on GitHub if you have any problems or suggestions.\n\n\n## License\n\nThe contents of this repository is released under the [MIT license](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpadosoft%2Flaravel-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpadosoft%2Flaravel-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpadosoft%2Flaravel-settings/lists"}