PHPackages                             frostie/silex-config-service-provider - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. frostie/silex-config-service-provider

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

frostie/silex-config-service-provider
=====================================

A config ServiceProvider for Silex with support for php, json and yaml.

v2.1(9y ago)077MITPHP

Since Jul 14Pushed 9y ago1 watchersCompare

[ Source](https://github.com/frostieDE/ConfigServiceProvider)[ Packagist](https://packagist.org/packages/frostie/silex-config-service-provider)[ RSS](/packages/frostie-silex-config-service-provider/feed)WikiDiscussions master Synced 2mo ago

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

ConfigServiceProvider
=====================

[](#configserviceprovider)

A config ServiceProvider for [Silex](http://silex.sensiolabs.org) with support for php, json, yaml, and toml.

Usage
-----

[](#usage)

### Passing a config file

[](#passing-a-config-file)

Pass the config file's path to the service provider's constructor. This is the recommended way of doing it, allowing you to define multiple environments.

```
$env = getenv('APP_ENV') ?: 'prod';
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__."/../config/$env.json"));

```

Now you can specify a `prod` and a `dev` environment.

**config/prod.json**

```
{
    "debug": false
}

```

**config/dev.json**

```
{
    "debug": true
}

```

To switch between them, just set the `APP_ENV` environment variable. In apache that would be:

```
SetEnv APP_ENV dev

```

Or in nginx with fcgi:

```
fastcgi_param APP_ENV dev

```

### Replacements

[](#replacements)

Also, you can pass an array of replacement patterns as second argument.

```
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__."/../config/services.json", array(
    'data_path' => __DIR__.'/data',
)));

```

Now you can use the pattern in your configuration file.

**/config/services.json**

```
{
    "xsl.path": "%data_path%/xsl"
}

```

You can also specify replacements inside the config file by using a key with `%foo%` notation:

```
{
    "%root_path%": "../..",
    "xsl.path": "%root_path%/xsl"
}

```

### Using Yaml

[](#using-yaml)

To use Yaml instead of JSON, just pass a file that ends on `.yml`:

```
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__."/../config/services.yml"));

```

Note, you will have to require the `~2.1` of the `symfony/yaml` package.

### Using TOML

[](#using-toml)

To use [TOML](https://github.com/mojombo/toml) instead of any of the other supported formats, just pass a file that ends on `.toml`:

```
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__."/../config/services.toml"));

```

Note, you will have to require the `~0.1` of the `jamesmoss/toml` package and you are using a bleeding edge configuration format, as the spec of TOML is still subject to change.

### Using plain PHP

[](#using-plain-php)

If reading the config file on every request becomes a performance problem in production, you can use a plain PHP file instead, and it will get cached by APC.

You'll have to rewrite your config to be a PHP file that returns the array of config data, and also make sure it ends with `.php`:

```
$app->register(new Igorw\Silex\ConfigServiceProvider(__DIR__."/../config/prod.php"));

```

### Multiple config files

[](#multiple-config-files)

You can use multiple config files, e. g. one for a whole application and a specific one for a task by calling `$app->register()` several times, each time passing another instance of `Igorw\Silex\ConfigServiceProvider`.

### Register order

[](#register-order)

Make sure you register ConfigServiceProvider last with your application. If you do not do this, the default values of other Providers will override your configuration.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 65.9% 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 ~143 days

Recently: every ~251 days

Total

13

Last Release

3325d ago

Major Versions

v1.2.2 → v2.0.02016-05-19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3764924?v=4)[Marcel Marnitz](/maintainers/frostieDE)[@frostieDE](https://github.com/frostieDE)

---

Top Contributors

[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (60 commits)")[![jeromemacias](https://avatars.githubusercontent.com/u/582446?v=4)](https://github.com/jeromemacias "jeromemacias (8 commits)")[![alcohol](https://avatars.githubusercontent.com/u/21414?v=4)](https://github.com/alcohol "alcohol (4 commits)")[![bobalazek](https://avatars.githubusercontent.com/u/1904053?v=4)](https://github.com/bobalazek "bobalazek (4 commits)")[![airdeck](https://avatars.githubusercontent.com/u/3452572?v=4)](https://github.com/airdeck "airdeck (3 commits)")[![rsvasyliev](https://avatars.githubusercontent.com/u/1588011?v=4)](https://github.com/rsvasyliev "rsvasyliev (2 commits)")[![fzerorubigd](https://avatars.githubusercontent.com/u/935155?v=4)](https://github.com/fzerorubigd "fzerorubigd (2 commits)")[![jbinfo](https://avatars.githubusercontent.com/u/761378?v=4)](https://github.com/jbinfo "jbinfo (2 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (2 commits)")[![frostieDE](https://avatars.githubusercontent.com/u/3764924?v=4)](https://github.com/frostieDE "frostieDE (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![gido](https://avatars.githubusercontent.com/u/101859?v=4)](https://github.com/gido "gido (1 commits)")[![danapplegate](https://avatars.githubusercontent.com/u/759698?v=4)](https://github.com/danapplegate "danapplegate (1 commits)")

---

Tags

silex

### Embed Badge

![Health badge](/badges/frostie-silex-config-service-provider/health.svg)

```
[![Health](https://phpackages.com/badges/frostie-silex-config-service-provider/health.svg)](https://phpackages.com/packages/frostie-silex-config-service-provider)
```

###  Alternatives

[igorw/config-service-provider

A config ServiceProvider for Silex with support for php, json and yaml.

215636.5k13](/packages/igorw-config-service-provider)[franmomu/silex-pagerfanta-provider

Silex ServiceProvider for Pagerfanta Library

1312.1k](/packages/franmomu-silex-pagerfanta-provider)[emanueleminotto/faker-service-provider

Faker Service Provider for Silex

162.9k](/packages/emanueleminotto-faker-service-provider)

PHPackages © 2026

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