PHPackages                             ecentria/dynamic-parameters-bundle - 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. ecentria/dynamic-parameters-bundle

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

ecentria/dynamic-parameters-bundle
==================================

Runtime retrieval of parameters from environment variables for Symfony

48.1k1PHP

Since Sep 16Pushed 6y ago10 watchersCompare

[ Source](https://github.com/ecentria/DynamicParametersBundle)[ Packagist](https://packagist.org/packages/ecentria/dynamic-parameters-bundle)[ RSS](/packages/ecentria-dynamic-parameters-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

DynamicParametersBundle
=======================

[](#dynamicparametersbundle)

Inspired by [incenteev/dynamic-parameters-bundle](https://github.com/Incenteev/DynamicParametersBundle) and [%env()%](http://symfony.com/blog/new-in-symfony-3-2-runtime-environment-variables) parameters in Symfony 3.2.

This bundle provides a way to read parameters from environment variables at runtime in Symfony 2.7 (and up) the same way as in Symfony 3.2 (some limitations apply).

[![Build Status](https://camo.githubusercontent.com/1a620d5542ddd45794aa76e06568dd5b19ad7d72468b076c4f6caf12e2a7329d/68747470733a2f2f6170692e7472617669732d63692e6f72672f6563656e747269612f44796e616d6963506172616d657465727342756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ecentria/DynamicParametersBundle)

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

[](#installation)

Installation is a 2 step process:

1. Download Ecentria fork of IncenteevDynamicParametersBundle
2. Enable the bundle

### Step 1: Install bundle with composer

[](#step-1-install-bundle-with-composer)

Run the following composer require command:

```
$ composer require ecentria/dynamic-parameters-bundle
```

### Step 2: Enable the bundle

[](#step-2-enable-the-bundle)

Finally, enable the bundle in the kernel:

```
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Incenteev\DynamicParametersBundle\IncenteevDynamicParametersBundle(),
    );
}
```

Usage
-----

[](#usage)

It's highly recommended to use %env()% parameters only as a value for regular parameter:

```
# app/config/parameters.yml
parameters:
    database_host: %env(DATABASE_HOST)%
```

and then `database_host` can be used in following scenarios:

```
parameters:
    # can be concatenated with strings/parameters
    dsn: mysql:host=%database_host%;dbname=testdb

    # can be used in array
    hosts:
        - localhost
        - %database_host%

# can be used in config
doctrine:
    dbal:
        connections:
            default:
                host: %database_host%

# can be used as service argument
services:
    foo:
        class: stdClass
        arguments:
            - %database_host%
```

Using `%env(DATABASE_HOST)%` directly (instead of `%database_host%`) has several disadvantages:

1. Environment variable name `DATABASE_HOST` is duplicated whenever dynamic parameter is used
2. This use case is not covered with tests as much as recommended one (yet), something might not work as expected

### Retrieving parameters at runtime

[](#retrieving-parameters-at-runtime)

The bundle takes care of service arguments, but changing the behavior of `$container->getParameter()` is not possible. However, it exposes a service to get parameters taking the environment variables into account.

```
$this->get('incenteev_dynamic_parameters.retriever')->get('database_host');
```

### Default values for dynamic parameters

[](#default-values-for-dynamic-parameters)

There are two options

#### (Recommended) Option 1: Using `.env` file (see [vlucas/phpdotenv](https://github.com/vlucas/phpdotenv))

[](#recommended-option-1--using-env-file-see-vlucasphpdotenv)

```
# .env file in project root
DATABASE_HOST="localhost"
```

This option is forward compatible with Symfony 3.2.

#### Option 2: Using `%default_env()%` parameters

[](#option-2-using-default_env-parameters)

```
parameters:
    database_host: %env(DATABASE_HOST)%
    default_env(DATABASE_HOST): localhost
```

This option is **not** forward compatible with Symfony 3.2, where default values are defined as follows:

```
parameters:
    database_host: %env(DATABASE_HOST)%
    env(DATABASE_HOST): localhost # doesn't work before Symfony 3.2
```

Limitations
-----------

[](#limitations)

- Getting a parameter from the container directly at runtime will not use the environment variable
- Uppercase names should be used for environment variables

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

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

---

Top Contributors

[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (8 commits)")[![RomanShumkov](https://avatars.githubusercontent.com/u/548534?v=4)](https://github.com/RomanShumkov "RomanShumkov (3 commits)")[![stanlemon](https://avatars.githubusercontent.com/u/86314?v=4)](https://github.com/stanlemon "stanlemon (1 commits)")

### Embed Badge

![Health badge](/badges/ecentria-dynamic-parameters-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/ecentria-dynamic-parameters-bundle/health.svg)](https://phpackages.com/packages/ecentria-dynamic-parameters-bundle)
```

###  Alternatives

[corviz/br-gpdpl

A lib that provides a series of data anonymizers, compliant with brazilian General Personal Data Protection Law (aka LGPD, in pt-br)

1613.6k](/packages/corviz-br-gpdpl)[afaya/edge-tts

Edge TTS is a PHP package that allows access to the online text-to-speech service used by Microsoft Edge without the need for Microsoft Edge, Windows, or an API key.

151.0k1](/packages/afaya-edge-tts)

PHPackages © 2026

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