Laravel Persistent Configuration

Laravel Persistent Configuration

Laravel Persistent Configuration is a package by Paul Klimov that provides persistent configuration for Laravel.

This extension allows reconfiguration of already created config repository using data from the external storage like relational database. It provides special config repository class, which wraps any given config repository, adding a layer for saving and restoring of data from persistent storage.

The package’s PersistentRepository class fully decorates any configuration repository implementing the \Illuminate\Contracts\Config\Repository interface. For example, the readme illustrates extending the Illuminate\Config\Repository service:

use Illuminatech\Config\StorageDb;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Config\Repository;
use Illuminatech\Config\PersistentRepository;

// ...

$this->app->extend('config', function (Repository $originConfig) {
    $storage = new StorageDb($this->app->make('db.connection'));

    $newConfig = (new PersistentRepository($originConfig, $storage))
        ->setItems([
            'mail.contact.address' => [
                'label' => __('Email address receiving contact messages'),
                'rules' => ['sometimes', 'required', 'email'],
            ],
            // ...
        ]);

    return $newConfig;
});

This package includes multiple storage options for saving and retrieving config values. Out of the box, the package consists of generic database storage, eloquent storage (stores configuration in Eloquent models), PHP, an array.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at illuminatech/config.


Filed in: News


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Senior Laravel Engineer
Remote okay (must already live in USA)
Hawthorne Effect
Senior Software Engineer (Remote - Contract)
Remote
Koodi Systems
PHP Developer
Pittsburgh / Remote
Sequoia Waste Solutions
Software Developer
Eindhoven
Simac IDS
Application Developer Level II (CakePHP / MySql / Vue.js)
Lancaster, PA
Harbor Compliance
FULL STACK LARAVEL DEVELOPER
LONDON - WEST END
AMPERSAND HEATLH
Mid/Senior Laravel Developer - U.S. Developers Only
Kenner, Louisiana
Profit Miner Technologies