Extensible site and user settings for Laravel.
Laravel Settings provides simple but flexible settings to any Laravel app.
- Quick to set up and use, but powerful enough to scale as your app does.
- Supports string and class based keys.
- Supports encryption and storing non-primitive values.
- User and global settings provided by default.
- Can add custom types such as a team or organisation.
We've taken care over documenting everything you'll need to get started and use Laravel settings fully.
Check out the docs on our documentation site.
echo \Settings\Setting::getValue('siteName') // My App
You can create settings in the service provider, in your boot
method
public function boot()
{
\Settings\Setting::createGlobal('siteName', 'My App', Field::text('siteName')->setValue('My App')->setLabel('The name of the site'));
\Settings\Setting::createUser('theme', 'default', Field::select('theme')->setValue('default')->setLabel('The theme to use')->withOption('default', 'Default'));
}
To make use of static analysis and IDE typehinting support, and to help you manage the defined settings, you can use class-based settings.
\Settings\Setting::setDefaultValue('theme', 'default-two'); // Set the default theme for users
\Settings\Setting::setDefaultValue('theme', 'my-custom-theme', 2); // User with an ID of `2` sets their own value.
All you need to do to use this project is pull it into an existing Laravel app using composer.
composer require twigger/laravel-settings
You can publish the configuration file by running
php artisan vendor:publish --provider="Settings\SettingsServiceProvider"
Contributions are welcome! Before contributing to this project, familiarize yourself with CONTRIBUTING.md.
This package is copyright © Toby Twigger and licensed for use under the terms of the MIT License (MIT). Please see LICENCE.md for more information.
For any questions, suggestions, security vulnerabilities or help, email me directly at tobytwigger1@gmail.com