{"id":14974811,"url":"https://github.com/mr-luke/settings-manager","last_synced_at":"2025-10-27T10:30:48.004Z","repository":{"id":46651017,"uuid":"154651015","full_name":"mr-luke/settings-manager","owner":"mr-luke","description":"Laravel package that provides settings manager with type casting.","archived":false,"fork":false,"pushed_at":"2023-05-12T11:54:44.000Z","size":146,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-28T19:23:42.932Z","etag":null,"topics":["cast","databse","json","laravel","laravel5","laravel6","laravel7","settings","settings-management"],"latest_commit_sha":null,"homepage":"","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/mr-luke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-25T10:17:50.000Z","updated_at":"2022-06-14T13:47:49.000Z","dependencies_parsed_at":"2023-02-17T13:05:24.053Z","dependency_job_id":null,"html_url":"https://github.com/mr-luke/settings-manager","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-luke%2Fsettings-manager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-luke%2Fsettings-manager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-luke%2Fsettings-manager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mr-luke%2Fsettings-manager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mr-luke","download_url":"https://codeload.github.com/mr-luke/settings-manager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219861563,"owners_count":16555990,"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":["cast","databse","json","laravel","laravel5","laravel6","laravel7","settings","settings-management"],"created_at":"2024-09-24T13:51:06.858Z","updated_at":"2025-10-27T10:30:47.651Z","avatar_url":"https://github.com/mr-luke.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Settings Manager - Laravel multibag settings Package.\n==============\n\n[![Latest Stable Version](https://poser.pugx.org/mr-luke/settings-manager/v/stable)](https://packagist.org/packages/mr-luke/settings-manager)\n[![Total Downloads](https://poser.pugx.org/mr-luke/settings-manager/downloads)](https://packagist.org/packages/mr-luke/settings-manager)\n[![License](https://poser.pugx.org/mr-luke/settings-manager/license)](https://packagist.org/packages/mr-luke/settings-manager)\n\n![Tests Workflow](https://github.com/mr-luke/settings-manager/actions/workflows/run-testsuit.yaml/badge.svg)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=mr-luke_settings-manager\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=mr-luke_settings-manager)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=mr-luke_settings-manager\u0026metric=security_rating)](https://sonarcloud.io/summary/new_code?id=mr-luke_settings-manager)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=mr-luke_settings-manager\u0026metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=mr-luke_settings-manager)\n\nThis package provides settings manamgement to your Laravel app with support of multiple setting bags with typed value.\n\n* [Getting Started](#getting-started)\n* [Installation](#installation)\n* [Configuration](#configuration)\n* [Usage](#usage)\n* [Plans](#plans)\n\n## Getting Started\n\nSetting Manager supported versions:\n* Laravel 10\n* Laravel 9\n* Laravel 8\n\n## Installation\n\nTo install through composer, simply put the following in your composer.json file and run `composer update`\n\n```json\n{\n    \"require\": {\n        \"mr-luke/settings-manager\": \"~2.0\"\n    }\n}\n```\nOr use the following command\n\n```bash\ncomposer require \"mr-luke/settings-manager\"\n```\n\nNext, add the service provider to `app/config/app.php`\n\n```\nMrluke\\Settings\\SettingsServiceProvider::class,\n```\n*Note: Package is auto-discoverable!*\n\n## Configuration\n\nTo use `SettingsManager` you need to setup your `Bags` first. Add your own one to the [config file](config/settings-manager.php) `bags`:\n\n```php\n'bags' =\u003e [\n    'general' =\u003e [ // Given key is used as a Bag name\n        'driver'   =\u003e 'database', // One of available drivers\n        'cache'    =\u003e true, // Should be Cached\n        'lifetime' =\u003e 60 // Cache lifetime in minutes\n\t],\n],\n```\n\nYou can setup different database connections or tables by new `driver` or different `json` files in:\n\n```php\n'drivers' =\u003e [\n    'database' =\u003e [\n        'class'      =\u003e \\Mrluke\\Settings\\Drivers\\Database::class,\n        'connection' =\u003e 'mysql',\n        'table'      =\u003e 'settings',\n    ],\n\n    'json' =\u003e [\n        'class' =\u003e \\Mrluke\\Settings\\Drivers\\Json::class,\n        'path'  =\u003e base_path('storage/app/settings/'),\n        'file'  =\u003e 'settings.json',\n    ]\n],\n```\n\nYou can also publish config file via command:\n```bash\nphp artisan vendor:publish\n```\n\n## Usage\n\n### Facade\n\nYou can access to `Manager` and your `Bags` using `Mrluke\\Settings\\Facades\\Settings`.\n\n### Type\n\n`SettingsManager` is a type casted tool that care about it during the whole process.\n\nExample: *You can pass `string 5.567` to `set` method for `ratio` setting (`float`) and `SettingsManager` will cast the value to `float 5.567` behind the scean.*\n\nWhereever you ask for certain key, it will always be correct type. But all begins at the point of `registering`...\n\n### Registering new index\n\nTo register new value use:\n```php\n$value = Settings::register(string $key, $value, string $type);\n```\nThis method returns given `$value` casted to given `$type`.\n\n### Accessing index\n\nTo get value use:\n```php\n$value = Settings::get(string $key, $default = null);\n```\nThis method returns `$default` in case given `$key` is not present in the `Bag`. Otherwise `$value` is casted to registered `type`.\n\n### Setting new value of index\n\nTo set new value use:\n```php\n$value = Settings::set(string $key, $value);\n```\nThis method returns `$value` casted to registered `type`. If given `$key` is not present, it will automaticaly call `register` method with auto-detected `type`.\n\n*This method shoud not be use to register settings in general! Use `Eventing` to detect all needed settings during development.*\n\n### Forgeting  an index\n\nTo forget an index use:\n```php\nSettings::forget(string $key);\n```\n\n### Default `Bag` vs specified\n\nTo access specific `Bag` use bag accessor method:\n ```php\n$value = Settings::bag(string $name)-\u003eget(string $key, $default = null);\n```\n\n### Helper\n\nYou can access to `SettingsManager` via helper function:\n```php\n// Get index\nsettings(string $key);\n// Set value\nsettings([string $key =\u003e $value]);\n// Get instance and perform action\nsettings()-\u003eforget(string $key);\n```\n\n### Events\n\n`SettingsManager` provides you a list of `pre` and `post` action events to help you handle different situations.\n\nExample: *You can use `Mrluke\\Settings\\Events\\Registered` event to prepare full list of production settings.*\n\nNamespace `Mrluke\\Settings\\Events`:\n\n* `Forgeting`\n* `Forgot`\n* `Loading`\n* `Loaded`\n* `Registering`\n* `Registered`\n* `Updating`\n* `Updated`\n\n### JSON Structure\n\n`SettingsManager` provides JSON Driver for configurations that can be share with front-end apps. The structure looks like this:\n\n```json\n{\n  \"key\": {\n    \"type\": \"\u003ctype\u003e\",\n    \"value\": \"\u003cvalue\u003e\"\n  },\n  \"another\": {\n    \"type\": \"\u003ctype\u003e\",\n    \"value\": \"\u003cvalue\u003e\"\n  }\n}\n```\n\n## Plans\n\n* Artisan Commands\n* Blade helpers for `bool` keys\n* Additional option to store `default` value from `get()` method\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-luke%2Fsettings-manager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmr-luke%2Fsettings-manager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmr-luke%2Fsettings-manager/lists"}