PHPackages                             e-artspace/pimple-env-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. e-artspace/pimple-env-provider

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

e-artspace/pimple-env-provider
==============================

A super simple, uSilex compatible, lightweight service provider to override Pimple container parameters with the value of environment variables.

2.0.1(6y ago)1113MITPHPCI failing

Since Oct 20Pushed 6y ago1 watchersCompare

[ Source](https://github.com/e-artspace/pimple-env-provider)[ Packagist](https://packagist.org/packages/e-artspace/pimple-env-provider)[ RSS](/packages/e-artspace-pimple-env-provider/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (2)Versions (4)Used By (0)

pimple-env-provider
===================

[](#pimple-env-provider)

[![Build Status](https://camo.githubusercontent.com/b618f990fec6cfcdd87cc5e3a6140412402146be54d240ad8d6fd83a6b49ad5c/68747470733a2f2f7472617669732d63692e6f72672f652d61727473706163652f70696d706c652d656e762d70726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/e-artspace/pimple-env-provider)[![Code Coverage](https://camo.githubusercontent.com/a1d08a731ccfd5e2def22444efc793636f2739a71768de822fda743b25e33991/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f652d61727473706163652f70696d706c652d656e762d70726f76696465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/e-artspace/pimple-env-provider/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a88ddfee38c9d1c15c12b665e46995bc755f8dcfc713e8d779d6f7e0cd5281c2/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f652d61727473706163652f70696d706c652d656e762d70726f76696465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/e-artspace/pimple-env-provider/?branch=master)

pimple-env-provider is a super simple, Silex compatible, lightweight service provider to allow overriding of Pimple container parameters with the value of environment variables.

Install
=======

[](#install)

```
> composer require e-artspace/pimple-env-provider

```

\#Usage

The container's parameters allowed to be overridden must be declared in env.prefix array. Foreach parameter a cast service name must be supplied (custom or predefined).

Call 'env.overload' before using the container.

```
putenv('DEBUG_APP=false');

$container = new \Pimple\Container([
	'debug.app'=> true
]);

$container->register(new \EnvProvider\EnvProvider([
	'env.vars'=>[
		'debug.app'=>'env.cast.boolean'
	]
]);

assert($container['debug.app'] === true);

$container['env.overload']; // this do the magic

assert($container['debug.app'] === false);
```

Predefined services:
--------------------

[](#predefined-services)

- *env.cast.strval*: cast to a string
- *env.cast.intval*: cast to a integer
- *env.cast.json\_decode*: to an array from a json string
- *env.cast.boolean*: cast to boolean 'true','TRUE' oe '1' =&gt; true otherwhise false
- *env.name.builder*: function to generate environment variable name, by default: *environment var name* = strtoupper((str\_replace('.', '\_', *container var name*)));
- *env.prefix*: a prefix for generated environment variable name (default is empty)

Create a new cast service:
--------------------------

[](#create-a-new-cast-service)

```
$container['env.cast.onoff'] = $app->protect(function($str) {
	return (0===strcasecmp('on',$str));
};
```

Customize *env.name.builder* service
------------------------------------

[](#customize-envnamebuilder-service)

```
$container['env.name.builder'] = app->protect(function($name) {
	return strtolower((str_replace('.', '-', $name)));;
})
```

Developing and Testing with docker
----------------------------------

[](#developing-and-testing--with-docker)

```
$ docker run --rm -ti -v $PWD/.:/app composer install
$ docker run --rm -ti -v $PWD/.:/app composer vendor/bin/phpunit

```

License
-------

[](#license)

(c) Enrico Fagnoni MIT License (see file)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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

Every ~533 days

Total

3

Last Release

2472d ago

Major Versions

1.0.0 → 2.0.02018-09-26

### Community

Maintainers

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

---

Top Contributors

[![ecow](https://avatars.githubusercontent.com/u/5788689?v=4)](https://github.com/ecow "ecow (8 commits)")

---

Tags

environmentservice providerpimple12factortwelve-factor appuSilex

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/e-artspace-pimple-env-provider/health.svg)

```
[![Health](https://phpackages.com/badges/e-artspace-pimple-env-provider/health.svg)](https://phpackages.com/packages/e-artspace-pimple-env-provider)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k627.3M6.1k](/packages/vlucas-phpdotenv)[symfony/dotenv

Registers environment variables from a .env file

3.8k237.6M2.6k](/packages/symfony-dotenv)[oat-sa/tao-core

TAO core extension

66140.1k108](/packages/oat-sa-tao-core)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73147.2k29](/packages/jaxon-php-jaxon-core)[tbachert/spi

Service provider loading facility

1118.6M8](/packages/tbachert-spi)[rochamarcelo/cake-pimple-di

A cakephp plugin for dependency injection based on Pimple library

12180.8k](/packages/rochamarcelo-cake-pimple-di)

PHPackages © 2026

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