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

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

gupalo/config-service-provider
==============================

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

2.0(1y ago)028MITPHP

Since Nov 15Pushed 1y agoCompare

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

READMEChangelogDependencies (4)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/da463657add438e44a71616721cb196380df420764b9c20c46e99f5f62098e34/68747470733a2f2f7472617669732d63692e6f72672f796f7573736d616e2f436f6e6669675365727669636550726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/youssman/ConfigServiceProvider)

> This repo is a fork of the lib [igorw/ConfigServiceProvider](https://github.com/igorw/ConfigServiceProvider) bringing support for Silex2. A pull request was submitted but not yet accepted.

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

[](#configserviceprovider)

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

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

[](#installation)

Put these lines to your composer.json:

```
"require": {
    "gupalo/config-service-provider": "^2.0"
},

```

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

25

—

LowBetter than 37% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.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

Unknown

Total

1

Last Release

544d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/df3e7060fb5777768e7bb133e98b1e7dfcc788f25fe6dc445acf7036da5c0c3e?d=identicon)[luchaninov](/maintainers/luchaninov)

---

Top Contributors

[![igorw](https://avatars.githubusercontent.com/u/88061?v=4)](https://github.com/igorw "igorw (60 commits)")[![youssman](https://avatars.githubusercontent.com/u/6182353?v=4)](https://github.com/youssman "youssman (9 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)")[![fzerorubigd](https://avatars.githubusercontent.com/u/935155?v=4)](https://github.com/fzerorubigd "fzerorubigd (2 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (2 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)")[![danapplegate](https://avatars.githubusercontent.com/u/759698?v=4)](https://github.com/danapplegate "danapplegate (1 commits)")[![luchaninov](https://avatars.githubusercontent.com/u/3829796?v=4)](https://github.com/luchaninov "luchaninov (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)")

---

Tags

phpsilex 2

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[imanghafoori/laravel-anypass

A minimal yet powerful package to help you in development.

21421.6k](/packages/imanghafoori-laravel-anypass)

PHPackages © 2026

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