amdadulhaq / setting-laravel
Setting option for Laravel
Fund package maintenance!
amdad121
Installs: 2 277
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/amdadulhaq/setting-laravel
Requires
- php: ^8.2|^8.3|^8.4|^8.5
- illuminate/contracts: ^10.0|^11.0|^12.0
- illuminate/database: ^10.0|^11.0|^12.0
- illuminate/support: ^10.0|^11.0|^12.0
Requires (Dev)
- driftingly/rector-laravel: ^1.0|^2.0
- larastan/larastan: ^2.0|^3.0
- laravel/pint: ^1.26
- orchestra/testbench: ^8.0|^9.0|^10.0
- pestphp/pest: ^2.0|^3.0|^4.0
- pestphp/pest-plugin-laravel: ^2.0|^3.0|^4.0
This package is auto-updated.
Last update: 2026-01-01 18:50:45 UTC
README
A minimal and powerful settings package for Laravel with caching, type casting, and bulk operations.
Features
- Simple key-value storage
- Automatic type casting (strings, integers, floats, booleans, arrays, JSON)
- Built-in caching for performance
- Bulk operations for setting/getting multiple values
- Facade support
- Configurable cache TTL
- Database storage
Installation
You can install the package via composer:
composer require amdadulhaq/setting-laravel
Requirements
- PHP 8.2, 8.3, 8.4, or 8.5
- Laravel 10, 11, or 12
You can publish and run the migrations with:
php artisan vendor:publish --tag="setting-laravel-migrations"
php artisan migrate
Optionally publish the config file:
php artisan vendor:publish --tag="setting-laravel-config"
Usage
Basic Usage
use AmdadulHaq\Setting\Facades\Setting; Setting::set('app_name', 'Laravel'); return Setting::get('app_name'); // Laravel Setting::remove('app_name'); // true Setting::has('app_name'); // false
Helper Function
setting()->set('app_name', 'Laravel'); return setting()->get('app_name'); // Laravel return setting()->remove('app_name'); // true
Type Casting
The package automatically casts values to their appropriate types:
setting()->set('string_value', 'Hello'); setting()->set('integer_value', 100); setting()->set('float_value', 15.5); setting()->set('boolean_value', true); setting()->set('array_value', ['foo' => 'bar']); setting()->set('json_value', ['nested' => ['key' => 'value']]); setting()->get('integer_value'); // Returns: 100 (int) setting()->get('boolean_value'); // Returns: true (bool) setting()->get('array_value'); // Returns: ['foo' => 'bar'] (array)
Default Values
setting()->get('nonexistent_key', 'default_value'); // default_value
Bulk Operations
// Set multiple settings at once setting()->setMultiple([ 'app_name' => 'Laravel', 'max_users' => 100, 'maintenance_mode' => false, ]); // Get multiple settings at once $settings = setting()->getMultiple(['app_name', 'max_users']); // ['app_name' => 'Laravel', 'max_users' => 100]
Get All Settings
$allSettings = setting()->all(); // Returns a Collection of all settings
Cache Management
// Manually flush the cache setting()->flushCache();
Configuration
The config file allows you to configure caching behavior:
return [ 'cache_enabled' => env('SETTING_CACHE_ENABLED', true), 'cache_key' => env('SETTING_CACHE_KEY', 'settings.cache'), 'cache_ttl' => env('SETTING_CACHE_TTL', 60 * 60 * 24), // 24 hours ];
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.