Cartalyst LLC.
Composite-config by Cartalyst

This package requires a valid subscription. Subscribe for access.


Cartalyst's Composite Config package enhances illuminate/config to allow configuration items to be placed within a database whilst cascading back to the filesystem.

This is super useful for building user interfaces that facilitate editing configuration for an app. Because it does not change the API for retrieving configuration items, it degrades gracefully to the filesystem if not present and requires zero changes to the places which use the configuration items.

The package follows the FIG standard PSR-4 to ensure a high level of interoperability between shared PHP code and is unit-tested.

Getting started

Have a read through the Installation Guide.

Quick Example

// Set config at runtime
Config::set($key, $value);

// Set persisting config at runtime
Config::getLoader()->set($key, $value);


The best way to install the Composite Config package is quickly and easily done with Composer.

Open your composer.json and add the following to the require array

"cartalyst/composite-config": "2.0.*"

Add the following lines after the require array on your composer.json file

"repositories": [
        "type": "composer",
        "url": ""

Note: Make sure your composer.json file is in a valid JSON format after the required changes.

Install the dependencies

Run Composer to install or update the new requirement.

php composer install


php composer update

Now you are able to require the vendor/autoload.php file to PSR-0 autoload the library.


// Include the composer autoload file
require_once 'vendor/autoload.php';

// Import the necessary classes
use Cartalyst\CompositeConfig\CompositeLoader;
use Illuminate\Config\Repository;
use Illuminate\Database\Connection;
use Illuminate\Filesystem\Filesystem;

// Setup config loader
$loader = new CompositeLoader(new Filesystem(), '/path/to/config/files');

// Attach the optional database loading functionality.
// Without this, the composite loader acts like the default file loader.
$database = new Connection(new PDO('mysql:dbname=my_database;host='), $prefix = '');

// Instantiate config
$config = new Repository($loader);

// Set persisting config
$config->getLoader()->set($key, $value);


Laravel 5

The Composite Config package has optional support for Laravel 5 and it comes bundled with a Service Provider for easier integration.

After you have installed the package correctly, just follow the instructions.

Open your Laravel config file config/app.php and add the following lines.

In the $providers array add the following service provider for this package.



Run the following commands to publish the migration and config files.

php artisan vendor:publish --provider="Cartalyst\CompositeConfig\Laravel\CompositeConfigServiceProvider"


Run the following command to migrate Sentinel after publishing the assets.

php artisan migrate


After publishing, the composite config config file can be found under config/cartalyst.composite-config.php where you can modify the package configuration.


Retrieving Config

Usage is identical to that explained in the Laravel documentation


Saving Config

There are two ways of saving configuration items.

1. Runtime

To set configuration at runtime, use

Config::set($key, $value);

During that request, calling Config::get($key); will return the value you have set.

Note: Configuration values that are set at run-time are only set for the current request, and will not be carried over to subsequent requests.

2. Persisting

To set persisting configuration at runtime, use

Config::persist($key, $value);

You wont find fancy lifestyle graphics and marketing bravado here. Just cold... hard... code...

Code Well, Rock On!
Processing Payment...