PHPackages                             saxulum/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. saxulum/config-service-provider

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

saxulum/config-service-provider
===============================

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

2.0.1(9y ago)1388.0k↓41.5%1[1 issues](https://github.com/saxulum-legacy/ConfigServiceProvider/issues)3MITPHPPHP &gt;=5.3.3,&lt;8.0

Since Jul 14Pushed 8y ago2 watchersCompare

[ Source](https://github.com/saxulum-legacy/ConfigServiceProvider)[ Packagist](https://packagist.org/packages/saxulum/config-service-provider)[ RSS](/packages/saxulum-config-service-provider/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (16)Used By (3)

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

[](#configserviceprovider)

[![Build Status](https://camo.githubusercontent.com/8243275c29ee438abfcab4bf92b8b4aa961b72ecb26020f49dd6fc1d77ac0ae6/68747470733a2f2f6170692e7472617669732d63692e6f72672f736178756c756d2f436f6e6669675365727669636550726f76696465722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/saxulum/ConfigServiceProvider)[![Total Downloads](https://camo.githubusercontent.com/b5a65649b315cb60403a2c98fd2e7fe95b06b77be7016a43f05d85099c8fcc60/68747470733a2f2f706f7365722e707567782e6f72672f736178756c756d2f636f6e6669672d736572766963652d70726f76696465722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/saxulum/config-service-provider)[![Latest Stable Version](https://camo.githubusercontent.com/7cbe0c8d646064c8907f47cdf3f8d3b699c6d4c69b7d23b1907b8daca5a36327/68747470733a2f2f706f7365722e707567782e6f72672f736178756c756d2f636f6e6669672d736572766963652d70726f76696465722f762f737461626c652e706e67)](https://packagist.org/packages/saxulum/config-service-provider)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a1e5caac7c94e71ff55c9d4f9a8e58c50eb60cfa691b87028d1882337979e824/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736178756c756d2f436f6e6669675365727669636550726f76696465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/saxulum/ConfigServiceProvider/?branch=master)

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.2` 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

42

—

FairBetter than 90% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community23

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 59.4% 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 ~110 days

Total

15

Last Release

3506d ago

Major Versions

v1.2.5 → 2.0.02015-12-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/55048de83ca5e5d8c67164a19c78edcaad413b0c1a4ae10d92edf8d77bedd90f?d=identicon)[dominikzogg](/maintainers/dominikzogg)

---

Top Contributors

[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (60 commits)")[![dominikzogg](https://avatars.githubusercontent.com/u/1011217?v=4)](https://github.com/dominikzogg "dominikzogg (11 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)")[![airdeck](https://avatars.githubusercontent.com/u/3452572?v=4)](https://github.com/airdeck "airdeck (3 commits)")[![ludofleury](https://avatars.githubusercontent.com/u/187038?v=4)](https://github.com/ludofleury "ludofleury (3 commits)")[![rsvasyliev](https://avatars.githubusercontent.com/u/1588011?v=4)](https://github.com/rsvasyliev "rsvasyliev (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)")[![fzerorubigd](https://avatars.githubusercontent.com/u/935155?v=4)](https://github.com/fzerorubigd "fzerorubigd (2 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)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![henrikbjorn](https://avatars.githubusercontent.com/u/19725?v=4)](https://github.com/henrikbjorn "henrikbjorn (1 commits)")

---

Tags

silexpimple

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[dflydev/doctrine-orm-service-provider

Doctrine ORM Service Provider

2081.7M35](/packages/dflydev-doctrine-orm-service-provider)[igorw/config-service-provider

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

215636.5k13](/packages/igorw-config-service-provider)[cilex/console-service-provider

Console Service Provider

273.1M3](/packages/cilex-console-service-provider)[rochamarcelo/cake-pimple-di

A cakephp plugin for dependency injection based on Pimple library

12176.8k](/packages/rochamarcelo-cake-pimple-di)[arokettu/phpstorm-metadata-export

Export PhpStorm Advanced Metadata from DI containers

1234.0k1](/packages/arokettu-phpstorm-metadata-export)

PHPackages © 2026

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