arandu/laravel-site-options
| Install | |
|---|---|
composer require arandu/laravel-site-options |
|
| Latest Version: | v4.1.0 |
| PHP: | ^8.2 |
| Laravel: | 11 · 12 · 13 |
| Older releases: | 8 · 9 · 10 |
| Last Updated: | Jul 1, 2026 |
| Links: | GitHub · Packagist |
Laravel Site Options
Laravel Site Options is a powerful yet easy-to-use package tailored for Laravel developers who need to manage global site settings effortlessly. Whether you're building a dynamic web application or a complex platform, this package provides a clean, intuitive interface to store and retrieve site-wide options with built-in caching for superior performance.
🚀 Installation
Getting started is simple. Install the package via Composer:
composer require arandu/laravel-site-options
Next, publish the configuration and migration files:
php artisan vendor:publish --provider="Arandu\LaravelSiteOptions\SiteOptionsServiceProvider"
Run the migration to create the necessary database table:
php artisan migrate
💡 Usage
Laravel Site Options offers a fluent API that makes managing site options a breeze:
use Arandu\LaravelSiteOptions\Option;
// Store options
Option::set('welcome_message', 'Hello, World!');
Option::set('site_settings', ['theme' => 'dark', 'layout' => 'wide']);
// Retrieve options
echo Option::get('welcome_message');
$settings = Option::get('site_settings', [
// ... the default settings
]);
// Check if an option exists
if (Option::has('maintenance_mode')) {
// Perform action
}
// Remove options
Option::rm('outdated_option');
For more details, check out the advanced usage section.
🌟 Features
- Feature Toggles: Easily manage feature flags for enabling or disabling features on the fly.
- Global Site Settings: Store and retrieve essential site settings like site name, logo, and more.
- Dynamic Content: Allow administrators to configure content such as footer phone numbers or popup delay times.
- And more: The possibilities are endless!
⚙️ Configuration
Customize the package settings in config/site-options.php:
table: Define the database table name for storing options.cache: Fine-tune caching settings.enabled: Toggle caching (true/false), configurable via.envasSITE_OPTIONS_CACHE_ENABLED.key: Set the cache key for storing options.ttl: Define cache TTL in minutes, configurable via.envasSITE_OPTIONS_CACHE_TTL.
hard_defaults: Specify hard-coded default values for options. If you specify a default value when callingOption::get(), that value will take precedence.
Modify config/site-options.php to fit your needs, and for environment-specific configurations, use the .env file.
🔄 Version Compatibility
Refer to the table below to match your Laravel version with the appropriate Laravel Site Options version:
| Laravel Framework | Laravel Site Options |
|---|---|
| 8.x | 1.x |
| 9.x | 2.x |
| 10.x | 3.x |
| 11.x, 12.x, 13.x | 4.x |
🛠️ Testing
composer test
🚨 Issues
Encounter a problem? Report it on our GitHub issue tracker.
🔒 Security
For security-related concerns, please refer to SECURITY.md.
🤝 Contributing
We welcome contributions from the community! Please read CONTRIBUTING.md to get started.
📜 License
This project is open-sourced under the MIT License. See the LICENSE file for more details.
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v4.1.0 | ^8.2 | ^11.0 || | ||
| v4.0.0 | ^8.2 | ^11.0 | ||
| v3.0.0 | ^8.1 | ^10.23 | ||
| v2.1.0 | ^8.0 | ^9.19 | ||
| v2.0.0 | ^8.0 | ^9.19 | ||
| v1.0.4 | ^7.4| | ^8.83 | ||
| v1.0.3 | ^7.4| | ^8.83 | ||
| v1.0.2 | ^7.4| | ^8.83 | ||
| v1.0.1 | ^7.3| | ^8.83 | ||
| v1.0.0 | ^7.3| | ^8.83 |