PHPackages                             cleancode/injectable-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/injectable-bundle

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

cleancode/injectable-bundle
===========================

Injectable-bundle is responsible for injecting array of objects into your class. By tagging you mark an service to be injected into your target service.

1.0.1(9y ago)174MITPHPPHP &gt;=7.0.0

Since Feb 26Pushed 9y ago1 watchersCompare

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

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

Injectable-Bundle
=================

[](#injectable-bundle)

#### Description

[](#description)

`Injectable-bundle` is responsible for injecting array of objects into your class. By tagging you mark an service to be injected into your target service.

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

##### Target Service

[](#target-service)

```
/**
* @DI\Service("template_factory")
*/
class TemplateFactory
{
    /**
    * @param array|Template[] $providers
    */
    private $providers;

    /**
     * @DI\InjectParams({
     *      "providers" = @DI\Inject("%empty_array%")
     * })
     */
    public function __construct(array $providers)
    {
        $this->providers = $providers;
    }

    public function createFor(string $type) : Template
    {
        foreach ($this->providers as $provider) {
            if ($provider->isHandling($type)) {
                return $provider;
            }
        }

        throw new \Exception("Template for {$type} doesn't exists!");
    }
}

interface Template
{
    public function render() : string

    public function isHandling(string $type) : bool;
}

```

##### Injected Services

[](#injected-services)

```
/**
 * @DI\Service()
 * @DI\Tag(name="injectable", attributes={"to"="template_factory", "index"="0"})
 */
class NiceTemplate implements Template
{
    public function render()
   {
        return "nice template";
   }

   public function isHandling(string $type) : bool
   {
        return $type === 'nice';
   }
}

/**
 * @DI\Service()
 * @DI\Tag(name="injectable", attributes={"to"="template_factory", "index"="0"})
 */
class UglyTemplate implements Template
{
    public function render()
   {
        return "ugly template";
   }

  public function isHandling(string $type) : bool
  {
       return $type === 'ugly';
  }
}

```

Above service will be injected into TemplateFactory.
If there will be no services tagged as injectable for `template_factory`, template factory will use of empty array.

### Understanding the annotations

[](#understanding-the-annotations)

```
@DI\Tag(name="injectable", attributes={"to"="template_factory", "index"="0"})

```

- `name="injectable"` - Marks service `to be used` by InjectableBundle
- `"to"="template_factory"` - Sets target service
- `"index"="0"` - Sets target service constructor argument index

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Every ~0 days

Total

2

Last Release

3365d 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 (6 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/cleancode-injectable-bundle/health.svg)](https://phpackages.com/packages/cleancode-injectable-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)
