PHPackages                             cleancode/feature-toggle-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. cleancode/feature-toggle-bundle

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

cleancode/feature-toggle-bundle
===============================

Feature toggle is responsible for switching service injection depending on configuration. Allowing to modify system behavior without changing code.

1.0.0(9y ago)015MITPHPPHP &gt;=7.0.0

Since Feb 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dgafka/feature-toggle-bundle)[ Packagist](https://packagist.org/packages/cleancode/feature-toggle-bundle)[ RSS](/packages/cleancode-feature-toggle-bundle/feed)WikiDiscussions master Synced 2mo ago

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

Feature-Toggle-Bundle
=====================

[](#feature-toggle-bundle)

#### Description

[](#description)

Feature toggle is responsible for `switching service injection depending on configuration`.
Allowing to modify system behavior without changing code.

### Example

[](#example)

Example use [JMSDiExtraBundle](https://github.com/schmittjoh/JMSDiExtraBundle), but you can easily configure it with `services.yml`

Let's say we want to store images. On developer machines we want to store them on file system, but anywhere else we want to store them on amazon.

```
interface PictureStorage
{
    /**
     * @param PictureWithContent $picture
     * @return void
     */
    public function store(string $pictureName, string $content);
}

/**
* @DI\Service("amazon_picture_storage")
* @DI\Tag(name="toggle", attributes={"for"="picture_storage", "on"="amazon_storage", "when"="enabled"})
*/
class AmazonPictureStorage
{
    public function store(string $pictureName, string $content)
    {
        // send it amazon
    }
}

/**
* @DI\Service("file_system_picture_storage")
* @DI\Tag(name="toggle", attributes={"for"="picture_storage", "on"="amazon_storage", "when"="disabled"})
*/
class FileSystemPictureStorage
{
    public function store(string $pictureName, string $content)
    {
        // save it locally
    }
}

```

Now when we have our services defined. We have to set default service, that will always be chosen, if all `when` specification fails. We are doing it by `service aliases`. The default for us is `amazon_picture_storage`

```
services.yml
    picture_storage:
       alias: amazon_picture_storage

```

We should also have the parameter, that we are using for deciding which implementation to pick.
In our example it's `amazon_storage`.

```
parameters.yml
    amazon_storage: "disabled"

```

We can make use of our storage now.

```
class AppController
{
    private $pictureStorage;

    /**
     * @DI\InjectParams({
     *      "pictureStorage" = @DI\Inject("picture_storage")
     * })
    */
    public function __construct(PictureStorage $pictureStorage)
    {
        $this->pictureStorage = $pictureStorage;
    }

    public function createPersonWithImage(string $pictureName, string $content)
    {
        $this->pictureStorage->store($pictureName, $content);
    }
}

```

###### Annotation Explained

[](#annotation-explained)

`@DI\Tag(name="toggle", attributes={"for"="picture_storage", "on"="amazon_storage", "when"="disabled"})`

- `name="toggle"` - Marks service `to be used` by FeatureToggleBundle
- `"for"="picture_storage"` - Which service alias will replaced
- `"on"="amazon_storage"` - Parameter name, that will be used for deciding, which one to inject
- `"when"="disabled"` - On what parameter value service containing this tag should be picked

So service that contains above tag will be used when `amazon_storage` parameters will be `equal to "disabled"`

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

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

3366d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1b6139b0dc15c550b22c76954ec6a96ac6c46b4c19b4a3c1e93c2146481e109e?d=identicon)[dgafka](/maintainers/dgafka)

---

Top Contributors

[![dgafka](https://avatars.githubusercontent.com/u/6060791?v=4)](https://github.com/dgafka "dgafka (2 commits)")

### Embed Badge

![Health badge](/badges/cleancode-feature-toggle-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/cleancode-feature-toggle-bundle/health.svg)](https://phpackages.com/packages/cleancode-feature-toggle-bundle)
```

###  Alternatives

[winzou/state-machine-bundle

Bundle for the very lightweight yet powerful PHP state machine

34010.4M15](/packages/winzou-state-machine-bundle)[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[sylius/taxonomy-bundle

Flexible categorization system for Symfony.

26388.2k7](/packages/sylius-taxonomy-bundle)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[sylius/addressing-bundle

Addressing and zone management for Symfony applications.

33221.4k3](/packages/sylius-addressing-bundle)[sylius/inventory-bundle

Flexible inventory management for Symfony applications.

19176.7k4](/packages/sylius-inventory-bundle)

PHPackages © 2026

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