PHPackages                             gobline/injector - 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. [Framework](/categories/framework)
4. /
5. gobline/injector

ActiveLibrary[Framework](/categories/framework)

gobline/injector
================

Injector component

v2.0.1(10y ago)131BSD-3-ClausePHPPHP &gt;=5.6.0

Since Oct 24Pushed 9y ago1 watchersCompare

[ Source](https://github.com/gobline/injector)[ Packagist](https://packagist.org/packages/gobline/injector)[ Docs](https://github.com/gobline)[ RSS](/packages/gobline-injector/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

Injector component
==================

[](#injector-component)

The Injector component allows you to inject dependencies with [Traits](http://php.net/manual/en/language.oop5.traits.php).

Usage
-----

[](#usage)

```
$injector = (new Gobline\Injector\TraitDependencyInjector())
    ->register("Dependency\\ServiceATrait", function ($o) use ($dic) { $o->setServiceA($dic['service.a']); });
    ->register("Dependency\\ServiceBTrait", function ($o) use ($dic) { $o->setServiceB($dic['service.b']); });

$injector->inject($consumer);
```

In the example above, if the consumer uses the `Dependency\\ServiceATrait` trait, the injector will then inject the matching service through the setter `setServiceA()` defined in the trait.

In order to do so, the injector makes use of [reflection](http://php.net/manual/en/class.reflectionclass.php) to find the traits that the consumer uses.

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

[](#installation)

You can install the Injector component using the dependency management tool [Composer](https://getcomposer.org/). Run the *require* command to resolve and download the dependencies:

```
composer require gobline/injector

```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity60

Established project with proven stability

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 ~22 days

Total

3

Last Release

3858d ago

Major Versions

v1.0.0 → v2.0.02015-12-03

PHP version history (2 changes)v1.0.0PHP &gt;=5.5.0

v2.0.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/1564a230fe2f5125b0504cf6b6fe1e829face1a5d20ec663b3b8d22843312c7d?d=identicon)[mdecaffmeyer](/maintainers/mdecaffmeyer)

---

Tags

dependency-injectiontraitgobline

### Embed Badge

![Health badge](/badges/gobline-injector/health.svg)

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

###  Alternatives

[jms/di-extra-bundle

Allows to configure dependency injection using annotations

32713.3M88](/packages/jms-di-extra-bundle)[rdlowrey/auryn

Auryn is a dependency injector for bootstrapping object-oriented PHP applications.

7352.3M77](/packages/rdlowrey-auryn)[yiisoft/injector

PSR-11 compatible injector. Executes a callable and makes an instances by injecting dependencies from a given DI container.

943.4M46](/packages/yiisoft-injector)[mouf/mouf

The Mouf PHP framework: an open-source PHP framework providing an easy way to download, install, use and reuse components, with a graphical user interface.

55146.3k17](/packages/mouf-mouf)[mouf/pimple-interop

This project is a very simple extension to the Pimple microframework. It adds to Pimple compatibility with the container-interop APIs.

102.5M2](/packages/mouf-pimple-interop)[lcobucci/di-builder

Dependency Injection Builder for PHP applications

34189.3k6](/packages/lcobucci-di-builder)

PHPackages © 2026

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