Download the PHP package webafra/larasettings without Composer
On this page you can find all versions of the php package webafra/larasettings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webafra/larasettings
More information about webafra/larasettings
Files in webafra/larasettings
Package larasettings
Short Description A Laravel 12/13 compatible package to store custom settings in database and cache, with auto-discovery and publishable migrations.
License MIT
Informations about the package larasettings
Laravel Setting (WebAfra)
A Laravel 12/13 compatible package to store custom settings in the database and cache, with auto-discovery, publishable migrations & models, and group-based organization.
Requirements
| Package version | Laravel | PHP |
|---|---|---|
^2.0 |
12, 13 | 8.2+ |
^1.0 |
12 | 8.1+ |
Installation
Note: Since this package supports Laravel auto-discovery, you do not need to manually register the ServiceProvider or Facade. If you prefer to register manually, add the following to
config/app.php:
Publishing Migrations & Models
Then run the migration:
Usage
Basic get / set
Groups
Settings can be organized into named groups (default group is general):
Primary settings
Primary settings are a special subset (e.g. site-wide configuration) that can be loaded all at once:
Bulk store
Cache management
All values are cached indefinitely via Cache::forever. To invalidate all cached settings:
API Reference
Setting::set()
Stores or updates a setting. Arrays are automatically JSON-encoded. Returns the stored value.
| Parameter | Type | Default | Description |
|---|---|---|---|
$key |
string |
— | Setting key |
$value |
mixed |
— | Value to store (arrays are JSON-encoded automatically) |
$is_primary |
bool |
false |
Mark as a primary setting |
$group |
string |
'general' |
Group namespace |
Setting::get()
Retrieves a setting value. Result is cached indefinitely.
| Parameter | Type | Default | Description |
|---|---|---|---|
$key |
string |
— | Setting key |
$default |
mixed |
null |
Fallback value if key does not exist |
$group |
string |
'general' |
Group namespace |
Setting::has()
Returns true if the setting exists in the database (does not hit cache).
Setting::delete()
Deletes a setting from the database and clears its cache entry. Returns true on success.
Setting::store()
Stores multiple settings at once. Returns the number of settings saved.
Setting::storePrimary()
Same as store() but marks every entry as primary (is_primary = true). Returns the number of settings saved.
Setting::getPrimary()
Returns all primary settings across all groups as a flat ['key' => 'value'] array. Result is cached indefinitely.
Setting::getGroup()
Returns all settings within a group as a ['key' => 'value'] array. Result is cached indefinitely.
Setting::clean()
Clears the cache for every setting, every group, and the primary collection. Does not delete database records.
Quick reference
| Method | DB read | DB write | Cache read | Cache write | Returns |
|---|---|---|---|---|---|
set() |
— | ✓ | — | ✓ | mixed |
get() |
on miss | — | ✓ | on miss | mixed |
has() |
✓ | — | — | — | bool |
delete() |
— | ✓ | — | clears | bool |
store() |
— | ✓ | — | ✓ | int |
storePrimary() |
— | ✓ | — | ✓ | int |
getPrimary() |
on miss | — | ✓ | on miss | array |
getGroup() |
on miss | — | ✓ | on miss | array |
clean() |
— | — | — | clears all | void |
Upgrading from v1.x
Version 2.0 introduced a group column and a composite unique key on (group, key). After upgrading the package, publish and run a new migration:
Existing rows will receive the default group value
general, so all existingSetting::get()andSetting::set()calls remain fully compatible without any code changes.
License
MIT
All versions of larasettings with dependencies
illuminate/support Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/cache Version ^12.0|^13.0