PHPackages                             frostiede/silex-environment-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. frostiede/silex-environment-serviceprovider

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

frostiede/silex-environment-serviceprovider
===========================================

v1.0.0(9y ago)0774MITPHPPHP &gt;=5.5

Since Oct 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/frostieDE/silex-environment-serviceprovider)[ Packagist](https://packagist.org/packages/frostiede/silex-environment-serviceprovider)[ RSS](/packages/frostiede-silex-environment-serviceprovider/feed)WikiDiscussions master Synced 2mo ago

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

Silex Environment ServiceProvider
=================================

[](#silex-environment-serviceprovider)

[![Build Status](https://camo.githubusercontent.com/e6d90bc9a940b9ee3789f1f79002bc2426aabe63ff4dd97323eb5046be1e10f6/68747470733a2f2f7472617669732d63692e6f72672f66726f7374696544452f73696c65782d656e7669726f6e6d656e742d7365727669636570726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/frostieDE/silex-environment-serviceprovider)[![Code Climate](https://camo.githubusercontent.com/ed36046b84010a6b44d7d8e7706ae9ce7198f96adb7e9031e0869515fe614711/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f66726f7374696544452f73696c65782d656e7669726f6e6d656e742d7365727669636570726f76696465722f6261646765732f6770612e737667)](https://codeclimate.com/github/frostieDE/silex-environment-serviceprovider)

ServiceProvider for Silex which empowers use of environments like prod, dev etc. Environments can be changed using an environment variable.

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

[](#installation)

```
$ composer require frostiede/silex-environment-serviceprovider

```

Afterwards, register the ServiceProvider:

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

Usage
-----

[](#usage)

You can now use `$app['env']` to get the current environment. Also, you can use `$app['cli']`to detect whether the current application is invoked by command line (in this case, it is set to `true`, `false` otherwise).

### CLI

[](#cli)

When invoking any command from CLI (e.g. using the Command extension), you should prepend the target environment:

```
$ APP_ENV=dev php bin/console your:command

```

### Webserver

[](#webserver)

Create two separate PHP endpoint files (`index.php` and `dev.php`) and set your environment variable according to the file. For example, `dev.php` should contain `putenv("APP_ENV=dev")` to make all requests from `dev.php` run in dev-environment.

**Note:** Ensure `dev.php` is not accessible in production!

Configuration
-------------

[](#configuration)

You can set the environment variable which this extension evaluates. As default, `APP_ENV` is used but you change it to whatever you want using the constructor:

```
$app->register(new EnvironmentServiceProvider('ENV'));
```

Contribution
============

[](#contribution)

Any help is welcomed. Feel free to create issues and merge requests :-)

License
=======

[](#license)

MIT License

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

3495d ago

### Community

Maintainers

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

---

Top Contributors

[![frostieDE](https://avatars.githubusercontent.com/u/3764924?v=4)](https://github.com/frostieDE "frostieDE (7 commits)")

---

Tags

silexpimple

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/frostiede-silex-environment-serviceprovider/health.svg)

```
[![Health](https://phpackages.com/badges/frostiede-silex-environment-serviceprovider/health.svg)](https://phpackages.com/packages/frostiede-silex-environment-serviceprovider)
```

###  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)
