Download the PHP package okipa/laravel-settings-management without Composer
On this page you can find all versions of the php package okipa/laravel-settings-management. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download okipa/laravel-settings-management
More information about okipa/laravel-settings-management
Files in okipa/laravel-settings-management
Package laravel-settings-management
Short Description An easy way to get access to your app settings from anywhere.
License MIT
Homepage https://github.com/Okipa/laravel-settings-management
Informations about the package laravel-settings-management
laravel-settings-management
An easy way to get access to your app settings from anywhere.
:warning: This package has been abandonned :warning:
Do not hesitate to contact me if you want to make it evolve and to maintain it.
Before starting
The settings management only uses one Model instance, which mean that using a database table to store your settings will read and update only one line.
Even if this package will work fine using database storage, using a Laravel Model Json Storage to do this can be a better option.
Installation
-
Install the package with composer :
-
Laravel 5.5+ uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider. If you don't use auto-discovery or if you use a Laravel 5.4- version, add the package service provider in the
register()
method from yourapp/Providers/AppServiceProvider.php
: -
Run the following command :
php artisan vendor:publish --tag=settingsManagement
.
This will publish these files to your project (to customize according to your needs) :app/Settings.php
: The Settings model.config/settings.php
: the settings management configuration file.database/migration/2018_05_16_145709_create_settings_table.php
: the settings management migration (delete this file if you chose to use the Laravel Model Json Storage).
-
Run the Laravel migration command :
php artisan migrate
- You may want to customize the
config/settings.php
configuration file values :model
: set the namespace of the model used for your app settings management.
Caution :
Your model-settings-management migration should have each of its field set as nullable()
or having a default value.
Without this configuration, a PDOException
would be thrown because an empty instance of the settings model is stored in database when none does exist.
Usage
Use the settings()
helper as a model instance to access to your settings data from anywhere in your app :
Update your settings data by using the settings()
helper as well.