PHPackages                             delatbabel/site-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. delatbabel/site-config

ActiveLibrary[Database &amp; ORM](/categories/database)

delatbabel/site-config
======================

A database backed config loader for Laravel with per-site configuration.

v1.1.3(9y ago)41.4k[2 issues](https://github.com/delatbabel/site-config/issues)2MITPHPPHP &gt;=5.4.0

Since Dec 29Pushed 8y ago5 watchersCompare

[ Source](https://github.com/delatbabel/site-config)[ Packagist](https://packagist.org/packages/delatbabel/site-config)[ RSS](/packages/delatbabel-site-config/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (9)Used By (2)

site-config
===========

[](#site-config)

A database backed config loader for Laravel with per-site configuration.

**THIS IS IN EARLY DEVELOPMENT STAGE, USE AT YOUR OWN RISK** -- most functions are now working and tested, although the phpUnit test cases won't run in the module. I have some codeception tests embedded in a sample application, yet to be published.

Features
--------

[](#features)

- Adds a websites table to store data for your websites that may change on a per-website basis.
- Adds a configs table that stores configuration data for your system that may change dynamically, or on a per-website or per-environment basis.
- Contains a bootstrapper that loads the database stored configuration into your website configuration, merging it with that loaded from the normal Laravel config files. So you can access stored config like normal Laravel config, e.g.

```
    // Access all configuration variables including Laravel + database stored configuration
    $config = config()->all();

    // Fetch a config variable by path
    $my_fruit = config('config.fruit');
```

- Database backed configuration is cached for up to 60 minutes to reduce the total amount of hits on your database.

Installation
------------

[](#installation)

Add the package using composer from the command line:

```
    composer require delatbabel\site-config

```

Alternatively, pull the package in manually by adding these lines to your composer.json file:

```
    "require": {
        "delatbabel/site-config": "~1.0"
    },

```

Once that is done, run the composer update command:

```
    composer update

```

### Register Service Provider

[](#register-service-provider)

After composer update completes, add this line to your config/app.php file in the 'providers' array:

```
    Delatbabel\SiteConfig\SiteConfigServiceProvider::class,

```

### Add the Facade to the Aliases

[](#add-the-facade-to-the-aliases)

In your config/app.php add this line to the aliases array:

```
    'SiteConfigSaver'   => Delatbabel\SiteConfig\Facades\SiteConfigSaver::class,

```

### Boostrap the Config Loader

[](#boostrap-the-config-loader)

Modify each of app/Console/Kernel.php and app/Http/Kernel.php to include the following bootstrappers function:

```
protected function bootstrappers()
{
    $bootstrappers = parent::bootstrappers();

    // Add the SiteConfig bootstrapper to the end.
    $bootstrappers[] = 'Delatbabel\SiteConfig\Bootstrap\LoadConfiguration';

    return $bootstrappers;
}
```

Note that Delatbabel\\SiteConfig\\Bootstrap\\LoadConfiguration is placed after the normal bootstrappers. You may of course already have a bootstrappers function in your Kernel.php files with other bootstrappers replaced, in which case you just need to modify it to include the updated LoadConfiguration bootstrapper code.

### Incorporate and Run the Migrations

[](#incorporate-and-run-the-migrations)

Finally, incorporate and run the migration scripts to create the database tables as follows:

```
php artisan vendor:publish --tag=migrations --force
php artisan migrate
```

There are some sample seedeers in database/seeds. You can copy these seeders in and use them as boilerplate for your own seeders in your own applications. They show how to populate the websites table and the configs table for some examples of global config as well as per-website and per-environment config.

TODO
====

[](#todo)

- More testing, bug fixing. I have tried to create a test suite using orchestra/testbench but it does not appear to work.
- Maybe a set of admin controllers/methods for updating the configuration.

Architecture
============

[](#architecture)

This section explains the architecture of the package and the decisions that I made while coding.

Design Goals
------------

[](#design-goals)

Having seen a few packages that provided database backed configuration for Laravel 4 I wanted something similar for Laravel 5 (I had previously worked on a similar system for Laravel 3). I also wanted the configuration to be stored in a single database, but to be variable on a per- website and per-environment basis.

I also wanted to have the configuration integrated with the base Laravel configuraton. The other packages that I have seen had their own Facades, so that accessing configuration worked like this:

```
    $var1 = config('mycode.mykey');  // Or use the facade Config::get('mycode.mykey');
    $var2 = DbConfig::get('mycode.mykey');
```

I wanted the two to be integrated so that I could use Config::get() regardless of where the configuration data came from. That means that I have to load all of the config data in the bootstrapper.

Bootstrapping
-------------

[](#bootstrapping)

Laravel includes a class called Illuminate\\Foundation\\Http\\Kernel which handles bootstrapping the application in Http mode, and a similar class for bootstrapping in Console mode. These two classes are normally extended in an application in the App\\Http\\Kernel and App\\Console\\Kernel classes respectively.

Each of these classes loads a bunch of core classes that need bootstrapping, including the Laravel logger.

Each of these classes contains a $bootstrappers array which contains the list of classes to be bootstrapped, and a bootstrappers() function which returns that array content. I was originally over-riding the $bootstrappers array but found that it varied between different patch releases of Laravel, so instead I have extended the bootstrappers() function (or at least provided documentation on how to extend it) so that it returns a modified version of the $bootstrappers array.

I initially tried to over-ride the Laravel provided LoadConfiguration bootstrapper, but in the Laravel bootstrap order that occurs before the database and the facades are available. So in the end I had to create a new LoadConfiguration bootstrapper and add it to the end of the $bootstrappers array so that it ran only after the database was available.

Repository
----------

[](#repository)

The Repository class, ConfigLoaderRepository, contains enough information to be able to load the **current** configuration from the database, including knowing about the current website and environment. The detecton of the environment and website, as well as the actual machinery of loading configuration for a generic website and environment, is left to the Model classes. The ConfigLoaderRepository class also handles all of the caching.

The ConfigSaverRepository class contains enough information to know which configuration values to store when saving configuration data to the database, and to reload it after it has been saved.

This provides a distinction between the business logic (deciding on what is to be done, and asking for it to be done) from the database model (loading or saving the data without making logic decisions).

Models
------

[](#models)

The model classes follow the standard Laravel paradigms but I have added a few extra functions to pull configuration data as required.

Thanks to the folks on StackOverflow DBA group who helped sort out the issues that I was having with the query in fetchSettings, and also to hailwood whose logic I pulled for the Models\\Config::set() function. As mentioned above there should be some further logic to assist in saving the config data, as well as some test cases to be developed.

Credits
=======

[](#credits)

Both of these packages were developed for Laravel 4 but provided some ideas:

-
-

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 84.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~73 days

Recently: every ~110 days

Total

7

Last Release

3343d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3bb12da0a07ef99daa73f6e75e84bc3e2e9f90a3523ab428e54deb38643876a?d=identicon)[delatbabel](/maintainers/delatbabel)

---

Top Contributors

[![delatbabel](https://avatars.githubusercontent.com/u/2335362?v=4)](https://github.com/delatbabel "delatbabel (39 commits)")[![haidangibm](https://avatars.githubusercontent.com/u/6229550?v=4)](https://github.com/haidangibm "haidangibm (7 commits)")

---

Tags

laravelconfigurationconfigdatabaseilluminatesite

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/delatbabel-site-config/health.svg)

```
[![Health](https://phpackages.com/badges/delatbabel-site-config/health.svg)](https://phpackages.com/packages/delatbabel-site-config)
```

###  Alternatives

[illuminatech/config

Provides support for Laravel application runtime configuration managed in persistent storage

14921.0k1](/packages/illuminatech-config)[arcanedev/laravel-settings

This package allows you to persists configs/settings for Laravel projects.

74131.4k6](/packages/arcanedev-laravel-settings)[mpyw/laravel-database-advisory-lock

Advisory Locking Features of Postgres/MySQL/MariaDB on Laravel

2860.5k](/packages/mpyw-laravel-database-advisory-lock)[cornford/setter

An easy way to integrate Database Settings with Laravel.

151.0k](/packages/cornford-setter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
