Download the PHP package diogo2550/database-system-setting without Composer
On this page you can find all versions of the php package diogo2550/database-system-setting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download diogo2550/database-system-setting
More information about diogo2550/database-system-setting
Files in diogo2550/database-system-setting
Package database-system-setting
Short Description Um simples plugin para abstrair o uso de configurações do sistema com o banco de dados.
License MIT
Informations about the package database-system-setting
Dynamic database settings without sacrificing performance or your Developer Experience (DX).
Database System Settings is an elegant Laravel package that solves a classic problem: how to give end-users (or administrators) control over settings without losing the framework's native features.
Administrative panel for the database-system-setting created with FilamentPHP.
📌 Why use this package?
In traditional Laravel applications, we rely on .env or static files in config/ to manage global variables. But what happens when you need to change the number of items displayed on the homepage, enable/disable an ad network, or change an API key without needing to deploy or access the server?
This package brings the best of both worlds: the flexibility of a database with the speed and predictability of native config files.
It's the perfect tool to integrate with modern admin panels (like FilamentPHP), allowing you to build amazing configuration interfaces in minutes.
✨ Highlighted Features
- 👨💻 Flawless DX: Native Autocomplete support in your IDE through the official Laravel extension. Forget the need to memorize database keys.
- ⚡ Performance First: Smart and automatic caching. Your settings are loaded from the database only once and kept in cache. The database is only queried again when a setting is changed.
- 🔄 Elegant Synchronization: Intuitive Artisan commands to sync, create, and prune orphan settings based on your schema.
- 🛠️ Zero Friction: Continue accessing your data exactly as you always have:
config('settings.my_key').
📦 Installation
Installation is quick and straightforward. Start by requiring the package via Composer:
Next, publish the configuration files and the migration:
Finally, run the migrations to create the system_settings table:
⚙️ How Configuration Works
The package's architecture is based on two main files published in your config/ folder:
settings.php: Where keys are mapped to ensure your IDE (VS Code, PhpStorm) can provide perfect autocomplete viaconfig().settings-schema.php: (Optional, but recommended) The heart of your validation. Here you define types, default values, and rules for your variables.
Building your Schema
The Schema is where you define the behavior and boundaries of your variables. Below is an example focused on a real application that needs to manage content rotation and monetization:
Syncing with the Database
After defining your schema, sync the information with the database. Existing values are always preserved!
Cleanup tip: Removed a setting from the code and want to delete it from the database? Use the
--pruneflag:php artisan database-system-setting:sync --prune
💻 Practical Usage
You don't need to learn a new syntax. Use the good old config() helper anywhere in your code: Controllers, Views (Blade), Middlewares, or Jobs.
🚀 The Cache Engine (Under the Hood)
Reading settings from the database on every request is the biggest performance mistake an application can make. Database System Settings solves this with a smart invalidatable cache flow:
- Application Boot: Laravel fetches the data from the database once and generates a cache with a 24-hour TTL.
- Subsequent Requests: Instant responses straight from the Cache (0 database queries).
- Automatic Invalidation: If you (or your Admin panel) perform an Update, Create, or Delete on the
SystemSettingmodel, the package destroys the cache instantly. The next request rebuilds the cache with fresh data.
Customizing the Cache
Need to disable the cache in the local environment or change the expiration time? Just edit the __internal__ key in the config/settings.php file:
📊 Database Structure
For reference, the system_settings table generated by the migration has the following structure:
| Column | Type | Functionality |
|---|---|---|
id |
bigint |
Primary key. |
key |
string |
Unique configuration key (e.g., site_name). |
value |
text |
Stored value (natively supports JSON). |
description |
text |
User-friendly description for admin panels. |
schema |
json |
Validation rules and metadata. |
updated_at |
timestamp |
Trigger for cache invalidation. |
🤝 Contributing
Contributions are always welcome! If you have ideas to improve the package, feel free to open an Issue or submit a Pull Request.
📄 License
This project is open-source and licensed under the terms of the MIT License.