laravel-settings maintained by stratos
Description
A flexible and extensible settings management package for Laravel applications
Author
Last update
2025/11/20 11:18
(dev-main)
License
Downloads
39
Tags
Laravel Settings
A flexible, enterprise-ready settings management package for Laravel applications. Manage global settings, user preferences, and dynamic configuration with powerful features including encryption, validation, audit trails, and granular permissions.
✨ Key Features
- 🌍 Global & User Settings - Application-wide and per-user preferences
- 🔒 Encryption - Secure sensitive data with Laravel's encryption
- ✅ Validation - Per-setting validation rules
- 📝 Audit Trail - Complete change history with rollback
- 🔐 Permissions - Role and permission-based access control
- 🌐 Multilingual - Translations for labels and descriptions
- ⚡ Caching - Automatic caching with smart invalidation
- 📦 Import/Export - Backup and migration (JSON/YAML)
- 🎯 Type Casting - Automatic type detection (string, int, bool, array, json)
- 🧪 Well Tested - 131 Pest tests with full coverage
📋 Requirements
- PHP 8.3 or higher
- Laravel 12.0 or higher
🚀 Quick Start
Installation
composer require stratos/laravel-settings
php artisan vendor:publish --tag="settings-migrations"
php artisan migrate
Basic Usage
use Stratos\Settings\Facades\Settings;
// Set a value
Settings::set('site.name', 'My Application');
// Get a value
$name = Settings::get('site.name', 'Default Name');
// Use helper
$name = setting('site.name');
// Blade directive
<h1>@setting('site.name')</h1>
User Settings
// Set user preference
Settings::user()->set('theme', 'dark');
// Get user preference
$theme = user_setting('theme', 'light');
// Blade
<body class="theme-@userSetting('theme')">
Advanced Features
// Encrypted values
Settings::setEncrypted('api.stripe_key', 'sk_live_...');
// With validation
Settings::setWithMetadata(
key: 'max_users',
value: 100,
validationRules: ['integer', 'min:1', 'max:1000']
);
// With permissions
Settings::setPermissions(
key: 'api.credentials',
viewType: 'roles',
viewPermissions: ['admin', 'developer'],
editType: 'roles',
editPermissions: ['admin']
);
// View history
$history = Settings::getHistory('site.name');
// Rollback
Settings::restoreToVersion('site.name', $historyId);
Artisan Commands
# Create setting interactively
php artisan settings:create
# Set a setting
php artisan settings:set site.name "My App"
# Get a setting
php artisan settings:get site.name
# List all settings
php artisan settings:list
# Export/Import
php artisan settings:export settings.json
php artisan settings:import settings.json
📚 Documentation
For complete documentation, visit the docs folder:
Getting Started
- Installation - Detailed setup and configuration
- Basic Usage - CRUD operations and helpers
- User Settings - Per-user preferences
Features
- Advanced Features - Validation, encryption, types, caching
- Permissions - Access control system
- Audit & History - Change tracking and rollback
- Import & Export - Backup and migration
- Events & Observers - Event system
Reference
- API Reference - Complete API documentation
- Artisan Commands - CLI reference
- REST API - HTTP endpoints
- Database Schema - Table structure
Guides
- Recipes - Practical examples
- Testing - Testing guide
- Migration Guides - Migrate from other packages
- Troubleshooting - Common issues
🎯 Use Cases
Perfect for:
- SaaS Applications - Per-tenant or per-user configuration
- API Credentials - Securely store API keys with encryption
- Feature Flags - Toggle features dynamically
- User Preferences - Theme, language, timezone, notifications
- Email Configuration - Dynamic SMTP settings
- Multi-Tenant Apps - Tenant-specific settings
- Enterprise Apps - Audit compliance and change tracking
🆚 Comparison
| Feature | Laravel Settings | Spatie Settings | Config Files |
|---|---|---|---|
| Global Settings | ✅ | ✅ | ✅ |
| User Settings | ✅ | ❌ | ❌ |
| Encryption | ✅ | ❌ | ❌ |
| Validation | ✅ | ❌ | ❌ |
| Permissions | ✅ | ❌ | ❌ |
| Audit Trail | ✅ | ❌ | ❌ |
| Import/Export | ✅ | ❌ | ❌ |
| History/Rollback | ✅ | ❌ | ❌ |
| Caching | ✅ | ✅ | ✅ |
| Dynamic Updates | ✅ | ✅ | ❌ |
🧪 Testing
# Run tests
vendor/bin/pest
# Run with coverage
vendor/bin/pest --coverage
📝 Changelog
See CHANGELOG.md for recent changes.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
🔒 Security
If you discover any security-related issues, please email security@stratosdigital.com instead of using the issue tracker.
📄 License
Laravel Settings is open-sourced software licensed under the MIT license.
👨💻 Credits
- Author: Mohamed Sabri Ben Chaabane
- Company: Stratos Digital
- Contributors: All Contributors
🌟 Support
If you find this package useful, please consider:
- ⭐ Starring the repository
- 🐛 Reporting issues
- 💡 Suggesting features
- 📖 Improving documentation