PHPackages                             ivoba/dotenv-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. ivoba/dotenv-service-provider

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

ivoba/dotenv-service-provider
=============================

A dotenv ServiceProvider for Silex.

2.0.0(9y ago)14.3k↓50%1[2 issues](https://github.com/ivoba/dotenv-service-provider/issues)MITPHPPHP &gt;=5.5.9

Since Jan 30Pushed 9y ago1 watchersCompare

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

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

DotenvServiceProvider
=====================

[](#dotenvserviceprovider)

A [dotenv](https://github.com/vlucas/phpdotenv) ServiceProvider for [Silex](http://silex.sensiolabs.org)

[![Build Status](https://camo.githubusercontent.com/8c8be965d4b9808a2dd3fc864451601aea04df55cb351d1c94843abc0281dbbe/687474703a2f2f696d672e736869656c64732e696f2f7472617669732f69766f62612f646f74656e762d736572766963652d70726f76696465722e737667)](https://travis-ci.org/ivoba/dotenv-service-provider)

#### Caution: this is highly overengineered!

[](#caution-this-is-highly-overengineered)

This will set all Env vars that have a given prefix, default is *SILEX\_*, to $app as parameters.
You can pass a function to detect if you want to run dotenv load as well to load vars from an .env file.

The functionality replaces mainly something like this:

```
$app['env'] = getenv('SILEX_ENV') ? getenv('SILEX_ENV') : 'dev';
if($app['env'] === 'dev'){
    \Dotenv::load();
}
$app['debug'] = getenv('SILEX_DEBUG') ? getenv('SILEX_DEBUG') : false;
$app['this'] = getenv('this') ? getenv('this') : 'that';
//...
\Dotenv::required();
```

About 10 LOC vs ca. 110 LOC + autoload, yiah
So its actually a bit overdressed for the party, but anyway ;)
Some goodies might be legit as getenv, $\_ENV &amp; $\_SERVER support.

Usage
-----

[](#usage)

Register the Service:

```
$app->register(new \Ivoba\Silex\EnvProvider(), ['env.options' => ['prefix' => 'MYPREFIX',
    'use_dotenv' => function () use ($app) {
        return $app['env'] === 'dev';
    },
    'dotenv_dir' => __DIR__ . '/../../../..',
    'var_config' => []]
]);
$app['env.load'];
```

Yo can add *default*, *required*, *allowed* and *typecast* config options for each var.

```
$envOptions = ['env.options' => ['var_config' => [
    'hoo' => [EnvProvider::CONFIG_KEY_ALLOWED => 'this'],
    'zack' => [EnvProvider::CONFIG_KEY_REQUIRED => true],
    'dong' => [EnvProvider::CONFIG_KEY_CAST => EnvProvider::CAST_TYPE_BOOLEAN],
    'zip' => [EnvProvider::CONFIG_KEY_DEFAULT => 'zippi']]
]];
$app->register(new \Ivoba\Silex\EnvProvider(), $envOptions);
$app['env.load'];
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 83.3% 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 ~160 days

Total

4

Last Release

3639d ago

Major Versions

1.1.1 → 2.0.02016-05-25

PHP version history (2 changes)1.0.0PHP &gt;=5.4

2.0.0PHP &gt;=5.5.9

### Community

Maintainers

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

---

Top Contributors

[![ivoba](https://avatars.githubusercontent.com/u/471254?v=4)](https://github.com/ivoba "ivoba (10 commits)")[![digitalkaoz](https://avatars.githubusercontent.com/u/293591?v=4)](https://github.com/digitalkaoz "digitalkaoz (2 commits)")

---

Tags

dotenvsilex

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ivoba-dotenv-service-provider/health.svg)

```
[![Health](https://phpackages.com/badges/ivoba-dotenv-service-provider/health.svg)](https://phpackages.com/packages/ivoba-dotenv-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)[yiithings/yii2-dotenv

PHP DotEnv for Yii2 framework

40574.5k7](/packages/yiithings-yii2-dotenv)[bnomei/kirby3-dotenv

Kirby Plugin for environment variables from .env

4144.1k1](/packages/bnomei-kirby3-dotenv)[beebmx/kirby-env

Enable env variables to Kirby

2037.9k2](/packages/beebmx-kirby-env)[johannschopplich/kirby-helpers

Environment, SEO, and build utilities for Kirby CMS

277.4k](/packages/johannschopplich-kirby-helpers)

PHPackages © 2026

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