Link Search Menu Expand Document

Laravel Settings

Contents
  1. Laravel Settings
    1. Introduction
    2. Installation
    3. Basic Usage

Introduction

Laravel Settings provides simple but flexible settings to any Laravel app.

  • Quick to get started.
  • Validation, encryption and authorization controls provided.
  • Global settings and user-set settings.
  • Native integration with Vue JS.
  • Auto generate UI for managing settings.

Installation

All you need to do to use this project is pull it into an existing Laravel app using composer.

composer require tobytwigger/laravel-settings

You can publish the configuration file by running

php artisan vendor:publish --provider="Settings\SettingsServiceProvider"

This will publish the configuration file and migrations.

Basic Usage

You can create a new setting in the boot method of any service provider.

    public function boot()
    {
        \Settings\Setting::createGlobal(
            key: 'siteName',
            defaultValue: 'My App'
        );
    }

This setting can then be accessed anywhere in your Laravel application

    echo \Settings\Setting::getValue('siteName') // My App

or updated to a new value

    \Settings\Setting::setValue('siteName', 'My New App');