PHPackages                             dotkernel/dot-dependency-injection - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. dotkernel/dot-dependency-injection

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

dotkernel/dot-dependency-injection
==================================

Dotkernel dependency injection component using class attributes.

1.3.0(6mo ago)332.1k↑76%1[1 issues](https://github.com/dotkernel/dot-dependency-injection/issues)[1 PRs](https://github.com/dotkernel/dot-dependency-injection/pulls)5MITPHPPHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0CI passing

Since Jun 7Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/dotkernel/dot-dependency-injection)[ Packagist](https://packagist.org/packages/dotkernel/dot-dependency-injection)[ Docs](https://github.com/dotkernel/dot-dependency-injection)[ RSS](/packages/dotkernel-dot-dependency-injection/feed)WikiDiscussions 1.0 Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (9)Used By (5)

dot-dependency-injection
========================

[](#dot-dependency-injection)

`dot-dependency-injection` is Dotkernel's dependency injection service.

By providing reusable factories for service and repository injection, it reduces code complexity in projects.

Documentation
-------------

[](#documentation)

Documentation is available at: .

Badges
------

[](#badges)

[![OSS Lifecycle](https://camo.githubusercontent.com/70efe9e0912dc533d2c5b31621a7ffb2b7cbda49a3063982e433e1ce51f7dc71/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e)](https://camo.githubusercontent.com/70efe9e0912dc533d2c5b31621a7ffb2b7cbda49a3063982e433e1ce51f7dc71/68747470733a2f2f696d672e736869656c64732e696f2f6f73736c6966656379636c652f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e)[![PHP from Packagist (specify version)](https://camo.githubusercontent.com/984766bbe8457604530f723171b7feb3899e2a4e0b0ac7621a9bdf93343bee02/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e2f312e332e30)](https://camo.githubusercontent.com/984766bbe8457604530f723171b7feb3899e2a4e0b0ac7621a9bdf93343bee02/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e2f312e332e30)

[![GitHub issues](https://camo.githubusercontent.com/a15bb3ceb949660fd76d0106ac7c31911329984452678cc13df2d67934242859/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e)](https://github.com/dotkernel/dot-dependency-injection/issues)[![GitHub forks](https://camo.githubusercontent.com/5ad627bea5b5ca3414f70f1aedf69bc0e8f826f05428278edbaf6ced0dd5be2b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e)](https://github.com/dotkernel/dot-dependency-injection/network)[![GitHub stars](https://camo.githubusercontent.com/4e316a1fe25a2c9a77423d054f2da70478bb2e2c70263a34413a592397345826/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e)](https://github.com/dotkernel/dot-dependency-injection/stargazers)[![GitHub license](https://camo.githubusercontent.com/a206944dee55706424cb4279c2d899996df8031e1d06b3aa05ccb179813508b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e)](https://github.com/dotkernel/dot-dependency-injection/blob/1.0/LICENSE.md)

[![Build Static](https://github.com/dotkernel/dot-dependency-injection/actions/workflows/continuous-integration.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-dependency-injection/actions/workflows/continuous-integration.yml)[![codecov](https://camo.githubusercontent.com/6d9801eedde052699f1d584b18110ad12893f90caf628c3bf2a598e870c027a5/68747470733a2f2f636f6465636f762e696f2f67682f646f746b65726e656c2f646f742d646570656e64656e63792d696e6a656374696f6e2f67726170682f62616467652e7376673f746f6b656e3d446179416f44324f6a36)](https://codecov.io/gh/dotkernel/dot-dependency-injection)[![docs-build](https://github.com/dotkernel/dot-dependency-injection/actions/workflows/docs-build.yml/badge.svg)](https://github.com/dotkernel/dot-dependency-injection/actions/workflows/docs-build.yml)[![PHPStan](https://github.com/dotkernel/dot-dependency-injection/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-dependency-injection/actions/workflows/static-analysis.yml)

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

[](#installation)

Install `dot-dependency-injection` by running the following command in your project directory:

```
composer require dotkernel/dot-dependency-injection
```

After installing, register `dot-dependency-injection` in your project by adding the below line to your configuration aggregate (usually: `config/config.php`):

```
Dot\DependencyInjection\ConfigProvider::class,
```

Usage
-----

[](#usage)

### Using the AttributedServiceFactory

[](#using-the-attributedservicefactory)

You can register services in the service manager using `AttributedServiceFactory` as seen in the below example:

```
return [
    'factories' => [
        ServiceClass::class => AttributedServiceFactory::class,
    ],
];
```

> You can use only the fully qualified class name as the service key

The next step is to add the `#[Inject]` attribute to the service constructor with the service FQCNs to inject:

```
#[\Dot\DependencyInjection\Attribute\Inject(
    App\Srevice\Dependency1::class,
    App\Srevice\Dependency2::class,
    "config",
)]
public function __construct(
    protected App\Srevice\Dependency1 $dep1,
    protected App\Srevice\Dependency2 $dep2,
    protected array $config
) {
}
```

The `#[Inject]` attribute is telling `AttributedServiceFactory` to inject the services specified as parameters. Valid service names should be provided, as registered in the service manager.

To inject an array value from the service manager, you can use dot notation as below

```
#[\Dot\DependencyInjection\Attribute\Inject(
    "config.debug",
)]
```

which will inject `$container->get('config')['debug'];`.

> Even if using dot notation, `AttributedServiceFactory` will check first if a service name exists with that name.

### Using the AttributedRepositoryFactory

[](#using-the-attributedrepositoryfactory)

You can register doctrine repositories and inject them using the `AttributedRepositoryFactory` as below:

```
return [
    'factories' => [
        ExampleRepository::class => AttributedRepositoryFactory::class,
    ],
];
```

The next step is to add the `#[Entity]` attribute in the repository class.

The `name` field has to be the fully qualified class name.

Every repository should extend `Doctrine\ORM\EntityRepository`.

```
use Api\App\Entity\Example;
use Doctrine\ORM\EntityRepository;
use Dot\DependencyInjection\Attribute\Entity;

#[Entity(name: Example::class)]
class ExampleRepository extends EntityRepository
{
}
```

> Dependencies injected via the`#[Entity]`/`#[Inject]` attributes are not cached

> Injecting dependencies into property setters is not supported

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance60

Regular maintenance activity

Popularity33

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 55.6% 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 ~85 days

Recently: every ~93 days

Total

7

Last Release

200d ago

PHP version history (3 changes)v1.x-devPHP ~8.2.0 || ~8.3.0

1.1.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0

1.3.0PHP ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1156873?v=4)[Dotkernel](/maintainers/dotkernel)[@dotkernel](https://github.com/dotkernel)

---

Top Contributors

[![alexmerlin](https://avatars.githubusercontent.com/u/4542449?v=4)](https://github.com/alexmerlin "alexmerlin (10 commits)")[![Howriq](https://avatars.githubusercontent.com/u/63609103?v=4)](https://github.com/Howriq "Howriq (4 commits)")[![arhimede](https://avatars.githubusercontent.com/u/22009710?v=4)](https://github.com/arhimede "arhimede (3 commits)")[![claurospace](https://avatars.githubusercontent.com/u/224870609?v=4)](https://github.com/claurospace "claurospace (1 commits)")

---

Tags

containerfactorydependencydiserviceinjectattribute

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dotkernel-dot-dependency-injection/health.svg)

```
[![Health](https://phpackages.com/badges/dotkernel-dot-dependency-injection/health.svg)](https://phpackages.com/packages/dotkernel-dot-dependency-injection)
```

###  Alternatives

[league/container

A fast and intuitive dependency injection container.

86787.8M343](/packages/league-container)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)[miladrahimi/phpcontainer

Dependency injection (IoC) container for PHP projects

1322.7k2](/packages/miladrahimi-phpcontainer)

PHPackages © 2026

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