PHPackages                             hco/auto-wiring-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. hco/auto-wiring-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

hco/auto-wiring-bundle
======================

0.9.3(12y ago)926MITPHP

Since Oct 3Pushed 12y ago5 watchersCompare

[ Source](https://github.com/hco/HCOAutoWiringBundle)[ Packagist](https://packagist.org/packages/hco/auto-wiring-bundle)[ RSS](/packages/hco-auto-wiring-bundle/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (4)Versions (5)Used By (0)

HCO Auto Wiring Bundle
======================

[](#hco-auto-wiring-bundle)

This bundle eases the usage of the symfony2 DIC by injecting (constructor) dependencies automatically.

All classes that should be autowired have to have a specific tag within the DIC. The Bundle will then iterate over the constructor-parameters and will try to find a service that satisfies the typehint of every parameter.

If there is not exactly one service that satisfies the typehint, the autowiring will fail. Qualifiers and Primary Services might help you to solve that issue, though :)

The autowiring process is done during compile time of the service container, which means that it **should not have any performance impact** in production.

Stability
---------

[](#stability)

I already use this bundle in an application, and it's working quite well. I am not yet releasing a 1.0 though, as I'm looking forward to feedback and experiences.

I intend to keep every change **backwards compatible**.

Qualifiers
----------

[](#qualifiers)

A service can have a so called "qualifier", which will allow autowiring of typehints which could be satisfied by several services.

An example could be your database connection. Imagine, you have two database connections within your service container, one for write requests and one for readonly requests. You could now give both services a qualifier, "write" for the write-database connection and "readonly" for the readonly database connection.

If a service now has an unqualified typehint for a database connection, the autowiring will fail. But you can now qualify a typehint with the string we used before, so that a service will be wired to one specific database connection.

Primary Services
----------------

[](#primary-services)

A service an be tagged to be a so called primary service. When a dependency should be outwired, and there is exactly one primary service, that will be outwired. There can still be several non-primary services for a class, but they will be ignored.

If two services are declared to be primary which are of the same type, the compilation of the container will fail.

Example
-------

[](#example)

Imagine you define the following class with the following service configuration

```
class ServiceWithDependency
{
    public $stdObject;

    public function __construct(StdClass $stdObject)
    {
        $this->stdObject = $stdObject;
    }
}
```

```

```

This will automatically inject the service *bar* into the service *foo*.

### Example with qualifiers

[](#example-with-qualifiers)

We're gonna reuse the *ServiceWithDependency* class from above, but modify the service configuration.

```

```

That will fail, as the autowiring bundle does not know which service should be injected anymore. This is where qualifiers come into play. We can slightly modify the class and service definition.

```
use HCO\AutoWiringBundle\Annotation\RequireQualifier;

class ServiceWithDependency
{
    public $stdObject;

    /**
     * @RequireQualifier(param="stdObject", qualifier="readonly")
     */
    public function __construct(StdClass $stdObject)
    {
        $this->stdObject = $stdObject;
    }
}
```

```

```

This will injcet the service *baz* into the service *foobar*, as *baz* is qualified as *readonly*.

Qualifiers can also be configured within the XML:

```

```

Something similar will work with YAML, as i just use tags on services.

### Example with Primary

[](#example-with-primary)

If we tag the service *baz* as primary, it will be used as the StdClass dependency of our *ServiceWithDependency*. See the following services.xml as an example.

```

```

License
=======

[](#license)

This bundle is under the MIT license. See the complete license in the LICENSE file in the root of this repository.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

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

4

Last Release

4647d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/532665404c27d9768cccd69ca00b00a3d812c5dc8dbad30e44a962877753d9a1?d=identicon)[hco](/maintainers/hco)

---

Top Contributors

[![hco](https://avatars.githubusercontent.com/u/156839?v=4)](https://github.com/hco "hco (27 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hco-auto-wiring-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/hco-auto-wiring-bundle/health.svg)](https://phpackages.com/packages/hco-auto-wiring-bundle)
```

PHPackages © 2026

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