PHPackages                             yosymfony/config-serviceprovider - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. yosymfony/config-serviceprovider

AbandonedLibrary[Parsing &amp; Serialization](/categories/parsing)

yosymfony/config-serviceprovider
================================

A configuration ServiceProvider for Silex based on Symfony Config component with support for YAML, TOML and JSON

v1.2.2(12y ago)71.1k1MITPHPPHP &gt;=5.3.0

Since Sep 16Pushed 12y ago1 watchersCompare

[ Source](https://github.com/yosymfony/ConfigServiceProvider)[ Packagist](https://packagist.org/packages/yosymfony/config-serviceprovider)[ RSS](/packages/yosymfony-config-serviceprovider/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (5)Dependencies (4)Versions (7)Used By (0)

Config ServiceProvider for Silex
================================

[](#config-serviceprovider-for-silex)

A configuration ServiceProvider for Silex based on [Symfony Config component](https://github.com/symfony/Config) with support for YAML, TOML (0.2.0) and JSON.

[![Build Status](https://camo.githubusercontent.com/a2675ad353113580f3f88c2bb2a68cbc50370078efdb1d6ead63418fcb4c974f/68747470733a2f2f7472617669732d63692e6f72672f796f73796d666f6e792f436f6e6669675365727669636550726f76696465722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/yosymfony/ConfigServiceProvider)[![Latest Stable Version](https://camo.githubusercontent.com/1ec8980ea20139726b3811b36574169784a4f9a41297d2e7ef27846773d5d53f/68747470733a2f2f706f7365722e707567782e6f72672f796f73796d666f6e792f636f6e6669672d7365727669636570726f76696465722f762f737461626c652e706e67)](https://packagist.org/packages/yosymfony/config-serviceprovider)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/5d04742beb1c9fd944912437a3f2d481ba6a45b4925c445b2057fafb2b0d6aee/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796f73796d666f6e792f436f6e6669675365727669636550726f76696465722f6261646765732f7175616c6974792d73636f72652e706e673f733d39333534633738386236363636383333326632313566356437643162373830396331646461656430)](https://scrutinizer-ci.com/g/yosymfony/ConfigServiceProvider/)[![Total Downloads](https://camo.githubusercontent.com/db3079897e891452d518998c5779e007d55cfe01a04a210ea2ec6c82ac44fa53/68747470733a2f2f706f7365722e707567782e6f72672f796f73796d666f6e792f636f6e6669672d7365727669636570726f76696465722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/yosymfony/config-serviceprovider)

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

[](#installation)

Use [Composer](http://getcomposer.org/) to install Yosyfmony ConfigServiceProvider package:

Add the following to your `composer.json` and run `composer update`.

```
"require": {
    "yosymfony/config-serviceprovider": "1.2-dev"
}

```

More informations about the package on [Packagist](https://packagist.org/packages/yosymfony/config-serviceprovider).

Usage
-----

[](#usage)

Register the ServiceProvider:

```
$app->register(new ConfigServiceProvider());

```

You can set a collection of locations where it should look for files and reference it only with the file's name

```
$app->register(new ConfigServiceProvider(array(
    __dir__.'/config',
    '/var/www/general-config'
)));

```

### Load a configuration file:

[](#load-a-configuration-file)

```
$repository = $app['configuration']->load('user.yml');

// or load with absolute path:
$repository = $app['configuration']->load('/var/config/user1.yml');

```

#### *.dist* files

[](#dist-files)

This library have support to `.dist` files. The location of a file follow the next hierachy:

- filename.ext
- filename.ext.dist (if filename.ext not exists)

### Load inline configuration:

[](#load-inline-configuration)

```
use Yosymfony\Silex\ConfigServiceProvider\Config;

$repository = $app['configuration']->load('server: "mail.yourname.com"', Config::TYPE_YAML);
// or
$repository = $app['configuration']->load('server = "mail.yourname.com"', Config::TYPE_TOML);

```

Repository
----------

[](#repository)

The configuration file is loaded to a repository. A repository is a wrapper with array access interface that supply methods for validating configurations values and merge with other repositories.

```
$repository->get('name', 'noname'); // If 'name' not exists return 'noname'
$repository['name']; // Get the element in 'name' key

```

### Validating configurations

[](#validating-configurations)

The values and the structure can be validated using a definition class from [Symfony Config component](http://symfony.com/doc/current/components/config/definition.html). For example, for this configuratión file:

```
# Yaml file
port: 25
server: "mail.yourname.com"

```

you can create the below definition:

```
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

class MyConfigDefinitions implements ConfigurationInterface
{
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root(0);

        $rootNode->children()
            ->integerNode('port')
                ->end()
            ->scalarNode('server')
                ->end()
        ->end();

        return $treeBuilder;
    }
}

```

and check your repository: `$repository->validateWith(new MyConfigDefinitions());`An exception will be thrown if any definition constraints are violated.

### Operations

[](#operations)

The operation ***mergeWith* was deprecated since version 1.2.0 and replaced by *union* method**.

#### Unions

[](#unions)

You can get the union of repository A with other B with C as result: `$resultC = $repositoryA->union($repositoryB);`. The values of `$repositoryB` have less priority than `$repositoryA`.

#### Intersections

[](#intersections)

You can get the intersection of repository A with other B with C as result: `$resultC = $repositoryA->intersection($repositoryB);`. The values of `$repositoryB` have less priority than `$repositoryA`.

### Create a blank repository

[](#create-a-blank-repository)

Create a blank repository is too easy. You only need create a instance of `ConfigRepository` and use the array interface or set method to insert new values:

```
use Yosymfony\Silex\ConfigServiceProvider\ConfigRepository;

//...

$repository = new ConfigRepository();
$repository->set('key1', 'value1');
// or
$repository['key1'] = 'value1';

```

and the next, you merge with others or validate it.

Unit tests
----------

[](#unit-tests)

You can run the unit tests with the following command:

```
$ cd your-path/vendor/yosymfony/config-serviceprovider
$ composer.phar install --dev
$ phpunit

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 60.5% 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 ~66 days

Total

5

Last Release

4406d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3321099?v=4)[Yo! Symfony](/maintainers/yosymfony)[@yosymfony](https://github.com/yosymfony)

---

Top Contributors

[![yosymfony](https://avatars.githubusercontent.com/u/3321099?v=4)](https://github.com/yosymfony "yosymfony (46 commits)")[![victorpuertas](https://avatars.githubusercontent.com/u/3154875?v=4)](https://github.com/victorpuertas "victorpuertas (30 commits)")

---

Tags

jsonconfigurationconfigyamlsilextoml

### Embed Badge

![Health badge](/badges/yosymfony-config-serviceprovider/health.svg)

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

###  Alternatives

[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97413.7M183](/packages/hassankhan-config)[m1/vars

Vars is a simple to use and easily extendable configuration loader with in built loaders for ini, json, PHP, toml, XML and yaml/yml file types. It also comes with in built support for Silex and more frameworks to come soon.

64124.3k1](/packages/m1-vars)[yosymfony/config-loader

Configuration file loader

10110.3k3](/packages/yosymfony-config-loader)[phppkg/config

Config manage, load, get. Supports INI,JSON,YAML,NEON,PHP format file

133.5k](/packages/phppkg-config)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[thewunder/conphigure

Framework Agnostic Configuration Library

3119.1k](/packages/thewunder-conphigure)

PHPackages © 2026

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