Search by

pharaonic / laravel-settings

Pharaonic

Typed, scoped application settings for Laravel: an Eloquent Setting model for global, named and per-model preferences, with explicit fallback, optional definitions and validation.

Package info

github.com/Pharaonic/laravel-settings

Documentation

pkg:composer/pharaonic/laravel-settings

Fund package maintenance!

MoamenEltouny

Buy Me A Coffee

Statistics

Installs: 467

Dependents: 0

Suggesters: 0

Stars: 7

Open Issues: 0

13.0.0 2026-11-10 06:19 UTC

README

PHP Version : 8.3 | 8.4 | 8.5 Laravel Version : 13.x License Build
Source Packagist Version Packagist Downloads

Typed settings for Laravel, global, named, or per model, stored through an Eloquent Setting model.


Installation

composer require pharaonic/laravel-settings
php artisan migrate

The service provider is registered automatically, and migrate creates the settings table. An application upgrading from 1.x converts its existing table with php artisan settings:migrate-legacy instead (a dry run until --apply). Publish the configuration to change the table, cache, casting policy, or definitions:

php artisan vendor:publish --tag=settings-config

Usage

use Pharaonic\Laravel\Settings\Concerns\HasSettings;

class Company extends Model
{
    use HasSettings;
}
settings()->setValue('site.name', 'Pharaonic');      // global, type string
settings('checkout')->setValue('minimum', 100);      // named scope, type integer
$company->setSetting('timezone', 'Africa/Cairo');    // model scope, written right away

settings()->getValue('site.name');                   // 'Pharaonic'
settings('checkout')->setValue('minimum', '100');    // SettingTypeMismatchException: stays an integer

$theme = settings($branch)
    ->fallbackTo($company)
    ->fallbackToGlobal()                             // then the global scope
    ->getValue('theme', 'light');

Setting::for($company)->where('type', 'string')->get(); // plain Eloquent: Setting models

Documentation

Full documentation: Laravel Settings Documentation.

Support & Security

See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.

License

MIT. See LICENSE.