PHPackages                             hendricha/tagpass - 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. hendricha/tagpass

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

hendricha/tagpass
=================

Simple symfony compiler passes for adding tagged services to other services

012PHP

Since Sep 12Pushed 10y ago1 watchersCompare

[ Source](https://github.com/hendricha/tagpass)[ Packagist](https://packagist.org/packages/hendricha/tagpass)[ RSS](/packages/hendricha-tagpass/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

TagPass and TargetedTagPass
===========================

[](#tagpass-and-targetedtagpass)

Simple solution to add Symfony service references to another service definitions by method calls, during container compile time.

Basically this library contains two configurable versions of the "Working with Tagged Services" example code of Symfony.

TagPass
-------

[](#tagpass)

This let's you collect all servcies with a certain tag and add them to a method call to a certain service or services. See the example below:

```
namespace AppBundle;

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use HendrichA\TagPassLibrary\TagPass;

class AppBundle extends Bundle
{
  public function build(ContainerBuilder $container)
  {
    parent::build($container);

    //This compiler pass will add all services tagged with foo to the
    //repository_of_all_things_foo service, by the addFoo method call.
    $fooPass = new TagPass('foo');
    $container->addCompilerPass(
      $fooPass->addServiceIdsTo('repository_of_all_things_foo', 'addFoo')
    );

    //You can add the tagged services to multiple service definitions too.
    $barPass = new TagPass('bar');
    $container->addCompilerPass(
      $barPass
        ->addServiceIdsTo('repository_of_all_things_bar', 'addBar')
        ->addServiceIdsTo('repository_of_all_the_things', 'addSomething')
      );
   }
}
```

TargetedTagPass
---------------

[](#targetedtagpass)

This compiler pass can add tagged services to other service definitions that are defined in the tag itself.

```
//SomeBundle.php
//...
$fooPass = new TargetedTagPass('form_extension', addExtension);
$container->addCompilerPass(fooPass);
```

```
#services.yml
services:
  login_form:
    class: LoginForm

  #This service will be added to login_form, because the tag specifies it
  login_extension:
    class: LoginExtension
    tags:
      - { name: form_extension, service: login_form }

  foo_form:
    class: Form
    tags:
      - { name: very_extensible_form }

  bar_form:
    class: Form
    tags:
      - { name: very_extensible_form }

  #This service will be added to both of the above service, since they are both
  #have the "very_extensible_form" tag
  foobar_extension:
    class: VeryExtensibleFormExtension
    tags:
      - { name: form_extension, tag: very_extensible_form }
```

\##Testing This repository contains functional tests for the compiler passes, that can be execute by phpunit. Because they require certain Symfony classes to be present, *phpunit* should be called from your symfony application root.

```
$ phpunit -c app/phpunit.xml vendor/hendricha/tagpass/HendrichA/TagPassLibrary/Tests
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![hendricha](https://avatars.githubusercontent.com/u/4252659?v=4)](https://github.com/hendricha "hendricha (7 commits)")

### Embed Badge

![Health badge](/badges/hendricha-tagpass/health.svg)

```
[![Health](https://phpackages.com/badges/hendricha-tagpass/health.svg)](https://phpackages.com/packages/hendricha-tagpass)
```

###  Alternatives

[denngarr/seat-fitting

Module to check fittings per character

1433.3k2](/packages/denngarr-seat-fitting)[thedmsgroup/mautic-enhancer-bundle

Various contact enhancer integrations for Mautic.

342.8k](/packages/thedmsgroup-mautic-enhancer-bundle)

PHPackages © 2026

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