{"id":19270993,"url":"https://github.com/postare/db-config","last_synced_at":"2026-01-16T01:01:41.356Z","repository":{"id":218890211,"uuid":"747094956","full_name":"postare/db-config","owner":"postare","description":"This Filament plugin enables you to create dynamic configuration pages for your Laravel project.","archived":false,"fork":false,"pushed_at":"2024-03-22T09:11:54.000Z","size":146,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-16T14:11:49.924Z","etag":null,"topics":["configuration","filament-plugin","filamentadmin","filamentphp","laravel"],"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/postare.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"postare"}},"created_at":"2024-01-23T08:57:22.000Z","updated_at":"2024-11-04T09:39:32.000Z","dependencies_parsed_at":"2024-01-24T11:42:45.238Z","dependency_job_id":"c9843a41-bdcc-410a-8320-64dc5e022bb0","html_url":"https://github.com/postare/db-config","commit_stats":null,"previous_names":["postare/db-config"],"tags_count":16,"template":false,"template_full_name":"filamentphp/plugin-skeleton","purl":"pkg:github/postare/db-config","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postare%2Fdb-config","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postare%2Fdb-config/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postare%2Fdb-config/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postare%2Fdb-config/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postare","download_url":"https://codeload.github.com/postare/db-config/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postare%2Fdb-config/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28475130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T00:15:39.755Z","status":"ssl_error","status_checked_at":"2026-01-16T00:15:32.174Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["configuration","filament-plugin","filamentadmin","filamentphp","laravel"],"created_at":"2024-11-09T20:28:36.232Z","updated_at":"2026-01-16T01:01:41.350Z","avatar_url":"https://github.com/postare.png","language":"PHP","readme":"# DB Config\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/postare/db-config.svg?style=flat-square)](https://packagist.org/packages/postare/db-config)\n[![Total Downloads](https://img.shields.io/packagist/dt/postare/db-config.svg?style=flat-square)](https://packagist.org/packages/postare/db-config)\n\nDB Config is a Filament plugin that provides a simple, database-backed key/value store for application settings, along with a streamlined way to build settings pages using Filament. It exposes a clean API for reading and writing values and uses transparent caching under the hood.\n\nIt is framework-friendly, requires no custom Eloquent models in your app, and persists values as JSON in a dedicated table.\n\n## Requirements\n\n- PHP version supported by your Laravel installation\n- Laravel 10, 11 or 12\n- A database engine with JSON support (MySQL 5.7+, MariaDB 10.2.7+, PostgreSQL, SQLite recent versions)\n- Filament 3.x or 4.x (see Compatibility)\n\n## Installation\n\nInstall the package via Composer (choose the version matching your Laravel version):\n\n```bash\ncomposer require postare/db-config:^2.0 # Laravel 10\ncomposer require postare/db-config:^3.0 # Laravel 11\ncomposer require postare/db-config:^4.0 # Laravel 12\n```\n\nPublish and run the migration:\n\n```bash\nphp artisan vendor:publish --tag=\"db-config-migrations\"\nphp artisan migrate\n```\n\nThis creates a `db_config` table used to store your settings.\n\n## Compatibility\n\n- Laravel 10 + Filament 3 → `postare/db-config:^2.0`\n- Laravel 11 + Filament 3 → `postare/db-config:^3.0`\n- Laravel 12 + Filament 4 → `postare/db-config:^4.0`\n\n## Usage of the `make:db_config` command\n\nThe package provides an Artisan generator that quickly creates a Filament settings page (Page class + Blade view).\n\nCommand:\n\n```bash\nphp artisan make:db_config {name} {panel?}\n```\n\nParameters:\n\n- `name`: the settings group name (e.g. `website`). It is used to generate the view name and the class name (singular, capitalized).\n- `panel` (optional): the Filament panel to create the page in (e.g. `Admin`). If omitted the default panel is used.\n\nExamples:\n\n```bash\nphp artisan make:db_config website\nphp artisan make:db_config website admin\n```\n\nWhat is generated:\n\n- A Page class at `app/Filament/{Panel}/Pages/{Name}Settings.php` (the class name is the singular form of `{name}` + `Settings`, e.g. `WebsiteSettings.php`).\n- A Blade view at `resources/views/filament/config-pages/{slug-name}-settings.blade.php` (the view name is a slugified version of the `name` with a `-settings` suffix).\n\nBehavior:\n\n- The command does not overwrite existing files: if the class or the view already exist it will warn and leave the files intact.\n- Names are normalized: the class uses the singular form of the provided name, the view is slugified (spaces and special characters are converted).\n\nNote: the generated class extends `Postare\\DbConfig\\AbstractPageSettings` and the view is placed under `resources/views/filament/config-pages/`.\n\n## How it works\n\nSettings are organized by a two-part key: `group.setting`, with optional nested sub-keys (e.g. `group.setting.nested.key`).\n\nUnder the hood:\n\n- Settings are stored in a single row per `(group, key)` with the JSON payload in the `settings` column.\n- Reads are cached forever under the cache key `db-config.{group}.{setting}`.\n- Writes clear the corresponding cache entry to keep reads fresh.\n\n## Filament integration\n\nThis package ships with an Artisan generator and an abstract Page class to quickly scaffold Filament settings pages.\n\nGenerate a settings page (and its Blade view):\n\n```bash\nphp artisan make:db_config website            # default panel\nphp artisan make:db_config website admin      # specific panel (e.g. Admin)\n```\n\nWhat gets generated:\n\n- A Page class in `app/Filament/{Panel}/Pages/*SettingsPage.php` that extends `Postare\\DbConfig\\AbstractPageSettings`.\n- A Blade view at `resources/views/filament/config-pages/{name}.blade.php` which renders the page content.\n\nPage lifecycle and saving:\n\n- On `mount()`, the page loads all settings for the given group (defined by `settingName()`) via `DbConfig::getGroup()` and fills the page content state.\n- A built-in header action “Save” persists the current state by calling `DbConfig::set(\"{group}.{key}\", $value)` for each top-level key present in the page content.\n\nDefining the page content:\n\n- Implement `protected function settingName(): string` to define the group name (e.g. `website`).\n- Implement `public function content(Schema $schema): Schema` and return your content schema.\n- Set `-\u003estatePath('data')` so the page state is bound to the `$data` property and saved correctly.\n\nExample page content (Filament schema):\n\n```php\nuse Filament\\Forms\\Components\\TextInput;\nuse Filament\\Schemas\\Schema; // or import the correct Schema depending on your setup\n\npublic function content(Schema $schema): Schema\n{\n    return $schema\n        -\u003ecomponents([\n            TextInput::make('site_name')-\u003erequired(),\n            // ... other inputs\n        ])\n        -\u003estatePath('data');\n}\n```\n\n## Database schema\n\nThe `db_config` table contains:\n\n- `id` (bigint, primary key)\n- `group` (string)\n- `key` (string)\n- `settings` (json, nullable)\n- `created_at`, `updated_at` (timestamps)\n\nThere is a unique index on (`group`, `key`). Timestamps are present but not used by the package logic and may remain null depending on your database defaults.\n\n## API\n\nThe package exposes a minimal API for interacting with settings.\n\nRead a value (helper):\n\n```php\ndb_config('website.site_name', 'Default Name');\n```\n\nRead a value (class):\n\n```php\n\\Postare\\DbConfig\\DbConfig::get('website.site_name', 'Default Name');\n```\n\nWrite a value:\n\n```php\n\\Postare\\DbConfig\\DbConfig::set('website.site_name', 'Acme Inc.');\n```\n\nRead an entire group as associative array:\n\n```php\n\\Postare\\DbConfig\\DbConfig::getGroup('website');\n// =\u003e [ 'site_name' =\u003e 'Acme Inc.', 'contact' =\u003e ['email' =\u003e 'info@acme.test'] ]\n```\n\nFacade (optional):\n\n```php\n\\Postare\\DbConfig\\Facades\\DbConfig::get('website.site_name');\n```\n\n\u003e The `db_config()` helper is auto-registered by the package and is the recommended way to read values in application code.\n\n## Keys and nested data\n\n- Keys are split by dots. The first segment is the `group`, the second is the top-level `setting`, and any remaining segments are treated as nested keys inside the stored JSON.\n- Example: `profile.preferences.theme` stores/reads from row `(group=profile, key=preferences)` and resolves the nested path `theme` inside the JSON payload.\n- Avoid using group-only keys (e.g. `profile`) — always specify at least `group.setting`.\n\nExamples:\n\n```php\n// Store a nested structure\n\\Postare\\DbConfig\\DbConfig::set('profile.preferences', [\n    'theme' =\u003e 'dark',\n    'notifications' =\u003e ['email' =\u003e true, 'sms' =\u003e false],\n]);\n\n// Read a nested value with default\ndb_config('profile.preferences.theme', 'light'); // 'dark'\n\n// Read a missing nested value\ndb_config('profile.preferences.timezone', 'UTC'); // 'UTC'\n```\n\n## Caching behavior\n\n- Reads are cached forever per `(group, setting)` to minimize database traffic.\n- `DbConfig::set()` automatically clears the cache for the affected `(group, setting)` pair.\n- When debugging, you can clear the framework cache (`php artisan cache:clear`) to reset all cached values.\n\n## Return values and defaults\n\n- If a value or nested path does not exist, the provided default is returned.\n- If the stored JSON value is `null`, the default is returned.\n- `getGroup()` returns an associative array of all settings for the group, or an empty array if none exist.\n\n## Database engines\n\nThis package stores settings as JSON. Ensure your chosen database supports JSON columns. For SQLite (common in tests), JSON is stored as text and works transparently for typical use cases.\n\n## Security considerations\n\n- Do not store secrets that belong in environment variables or the configuration cache (API keys, DB credentials). Use this package for runtime-editable application settings (e.g. labels, feature flags, contact info).\n- Values are not encrypted by default. If you need encryption, wrap reads/writes with your own encryption layer before passing to the API.\n\n## Versioning\n\nThis package follows semantic versioning. Use a version constraint compatible with your Laravel version as shown in the installation section.\n\n## License\n\nThe MIT License (MIT). See the LICENSE file for more details.\n","funding_links":["https://github.com/sponsors/postare"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostare%2Fdb-config","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostare%2Fdb-config","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostare%2Fdb-config/lists"}