PHPackages                             bluesteel42/settings-bundle - 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. bluesteel42/settings-bundle

ActiveSymfony-bundle

bluesteel42/settings-bundle
===========================

The BlueSteel42 Settings Bundle

v1.0.3(9y ago)023[1 issues](https://github.com/BlueSteel42/SettingsBundle/issues)MITPHPPHP &gt;=5.3.9

Since Apr 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/BlueSteel42/SettingsBundle)[ Packagist](https://packagist.org/packages/bluesteel42/settings-bundle)[ Docs](https://github.com/BlueSteel42/SettingsBundle)[ RSS](/packages/bluesteel42-settings-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

SettingsBundle
==============

[](#settingsbundle)

A Symfony 2.7+ bundle which allows you to store multiple project configuration settings using different backends for data storage.

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

[](#installation)

Add this bundle to your project as a composer dependency: simply add a dependency on `bluesteel42/settings-bundle` to your project's `composer.json` file. Here is a minimal example of a `composer.json` file that just defines a dependency on SettingsBundle:

```
    {
        "require": {
            "bluesteel42/settings-bundle": "~1.0"
        }
    }

```

Add the bundle in your application kernel:

```
// app/AppKernel.php
public function registerBundles()
{
    // ...
    $bundles[] = new BlueSteel42\SettingsBundle\BlueSteel42SettingsBundle();
}
```

Backend Configuration
---------------------

[](#backend-configuration)

The SettingsBundle works out of the box without the needing of specific configuration, using the Yaml backend by default and storing data under `%kernel.root_dir%/Resources directory`. If you need to use a different backend just put it in your `config.yml`:

```
bluesteel42_settings: xml
```

Valid backends are: `yml`, `xml`, `doctrinedbal`.

### Yaml and XML backends

[](#yaml-and-xml-backends)

`yml` and `xml` backends store data in a file. In order to change the default directory under which the file is stored you must use the extended configuration:

```
bluesteel42_settings:
    backend: xml
        path: path/to/my/dir
```

### Doctrine DBAL backend

[](#doctrine-dbal-backend)

This backend stores data in a database table. By default it uses the `bluesteel42_settings` table and the Doctrine connection named `default`.
You can modify one or both these parameters with the extended configuration:

```
bluesteel42_settings:
    backend: doctrinedbal
        connection: my_connection
        table: my_settings_table
```

The table can be created using the console command

```
bluesteel42_settings:install
```

Please see the command help for more information.

Cache Configuration
-------------------

[](#cache-configuration)

The SettingsBundle uses a cache to speed-up data loading and provides adapters for **Memcached** and **file-based cache**. A special **Null** adapter is also provided to let you disable the cache for debugging purposes. The **Null** adapter is enabled by default.

Each cache adapter has specific configuration options.

### NullCache

[](#nullcache)

Since this adapter is enabled by default the following configurations are equivalent:

```
    bluesteel42_settings:
        cache: ~
```

```
    bluesteel42_settings:
        cache: 'null'
```

```
    bluesteel42_settings:
        cache:
            'null': true
```

This adapter does note have further configuration parameters.

### File-based cache

[](#file-based-cache)

This adapter stores the cached data in a cache file placed by default under the `%kernel.cache_dir%/bluesteel42_settings` directory. This adapter can be enabled with its default configuration with the following keys in your `config.yml`:

```
    bluesteel42_settings:
        cache: file
```

If you need to modify the default path under which the cache file is stored just the `path` key:

```
    bluesteel42_settings:
        cache:
            file:
                path: 'path/to/my/cache/dir'
```

It is **strongly recommended** to keep the cache file somewhere under `%kernel.cache_dir%`in order to have it cleaned up every time you invoke a `cache:clear` console command.

### Memcached

[](#memcached)

This adapter uses the `php-memcached` extension to store cached data under **one or more**memcached servers. Each server must be specified as in the following example:

```
    bluesteel42_settings:
        cache:
            memcached:
                servers:
                    - { host: localhost, port: 11211 }
                    - { host: my_remote_cache_server, port: 11222 }
```

Usage
-----

[](#usage)

The SettingsBundle exposes a `bluesteel42.settings` that acts as a *settings repository*.
Each setting *value* is identified by a *key*. You can use a dot (`.`) to create a key hierarchy.

### Get values

[](#get-values)

Keys can be retrieved using the method `get($key, $default = null)`

```
//  Get the service
$service = $this->get('bluesteel42.settings');
//  Get a key
$value = $service->get('my_key');
// Get a subkey
$subValue = $service->get('second_key.sub_key.third_level_key');
// Get a key with a default value if not found
$items_per_page = $service->get('items_per_page', 10);
```

### Set values

[](#set-values)

A key value can be set using the method `set($key, $value)`.

```
//  Set a key
$service->set('items_per_page', 20);
//  Set a subkey
$service->set('my_key.sub_key','subval1');
```

If the value is an array, a subkey is created for each key of the array.

```
$myArray = array('first' => 'red', 'second' => 'blue', 'third' => 'yellow');
$service->set('colors', $myArray);
echo $service->get('colors.first'); // outputs 'red'
```

Note that when a key is set the old value will be overridden regardless the existance or not of subkeys. For instance, following the example above:

```
$service->set('colors', 'black and white');
echo $service->get('colors.first'); // outputs null
echo $service->get('colors'); // outputs 'black and white'
```

### Delete values

[](#delete-values)

A key can be deleted using the method `delete($key)`. The given key and all its subkeys (if any) will be deleted.

```
//  Delete a key
$service->delete('my_key');
```

### Persist changes

[](#persist-changes)

Every set of changes must be explicitly persisted. If not, changes will be lost at the end of the execution.
Changes will be persisted by invoking the method `flush()`.

```
//  Flush Modification
$service->flush();
```

Tips
----

[](#tips)

### Get or set all keys in a single call

[](#get-or-set-all-keys-in-a-single-call)

You can retrieve all keys with one single call with the method `getAll()` and set all key values with `setAll(array $values`.
Note that since by using subkeys you define a hierarchy the method `getAll()` returns a multidimensional array and - obviously - the method `setAll()` needs a multidimensional array in order to store the data set correctly.

```
$allValues = array('colors.first' => 'red', 'colors.second' => 'blue'); // wrong

//correct
$allValues =
    array(
        'colors' =>
            array(
                'first' => 'red',
                'second' => 'blue'
            )
    );

$service->setAll($allValues);
```

### Chainability

[](#chainability)

The method `set($key, $value)` allows you to chain calls:

```
$service->set('controller.one', 1)
    ->set('controller.two', 2)
    ->set('controller.three', 3)
    ->set('controller.four', 4)
    ->flush();
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 67.3% 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 ~45 days

Total

5

Last Release

3504d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ed54785e62489275d82c7caf5a3c2987bf18765b159c400c0be45ac1f2936e0?d=identicon)[plutonio21](/maintainers/plutonio21)

---

Top Contributors

[![plutonio21](https://avatars.githubusercontent.com/u/16163823?v=4)](https://github.com/plutonio21 "plutonio21 (33 commits)")[![umbe81](https://avatars.githubusercontent.com/u/17640365?v=4)](https://github.com/umbe81 "umbe81 (15 commits)")[![imtumbertostefani](https://avatars.githubusercontent.com/u/17705848?v=4)](https://github.com/imtumbertostefani "imtumbertostefani (1 commits)")

---

Tags

bundlephpsymfonysymfony-bundleSettings

### Embed Badge

![Health badge](/badges/bluesteel42-settings-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/bluesteel42-settings-bundle/health.svg)](https://phpackages.com/packages/bluesteel42-settings-bundle)
```

###  Alternatives

[chillerlan/php-settings-container

A container class for immutable settings objects. Not a DI container.

3427.3M21](/packages/chillerlan-php-settings-container)[dmishh/settings-bundle

Database centric Symfony configuration management. Global and per-user settings supported.

115254.9k1](/packages/dmishh-settings-bundle)[jbtronics/settings-bundle

A symfony bundle to easily create typesafe, user-configurable settings for symfony applications

9546.7k2](/packages/jbtronics-settings-bundle)

PHPackages © 2026

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