Overview

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

Instead of a handwritten factory class per service, you declare a class's dependencies with the #[Inject] attribute on its constructor - or a repository's entity with #[Entity] - and register one of the two reusable factories this package ships. That removes an entire category of boilerplate files from a project and keeps the dependency list next to the constructor it feeds.

It provides:

  • Dot\DependencyInjection\Attribute\Inject - declares the dependencies of a constructor
  • Dot\DependencyInjection\Attribute\Entity - declares the entity of a Doctrine repository
  • Dot\DependencyInjection\Factory\AttributedServiceFactory - builds any class from its #[Inject] attribute
  • Dot\DependencyInjection\Factory\AttributedRepositoryFactory - builds any Doctrine repository from its #[Entity] attribute

Continue with Attributes vs. factories for the comparison and the trade-offs, or with Installation.

Badges

OSS Lifecycle PHP from Packagist (specify version)

GitHub issues GitHub forks GitHub stars GitHub license

Build Static codecov docs-build PHPStan

On this page