weew / container-doctrine-integration
Make doctrine repositories injectable in the weew/container.
Requires
- doctrine/orm: ^2.5
- weew/container: ^1.0
Requires (Dev)
- phpunit/phpunit: ^4.7
- satooshi/php-coveralls: ^0.6.1
This package is not auto-updated.
Last update: 2024-11-19 22:36:29 UTC
README
Table of contents
Installation
composer require weew/container-doctrine-integration
Introduction
Doctrine repositories are not injectable on their own since they are not easily instantiable. To make it work you'll have to work with factories do some argument parsing and so on. This is exactly what this package does, it makes doctrine repositories injectable trough the weew/container container.
Conventions
There are certain conventions that you must follow to be able to inject doctrine repositories. Repositories loader does this kind of repository name to entity name conversion:
Vendor\Package\Repositories\FooRepository
should map to this entity Vendor\Package\Entities\Foo
.
If this name matching strategy is not sufficient for you, you may provide your own implementation of the IRepositoryNameParser
interface.
Usage
To make repositories injectable simply create a new instance of IDoctrineRepositoriesLoader
, pass in an instance of IContainer
and an instance ObjectManager
and enable it.
$loader = new DoctrineRepositoriesLoader($container, $om); $loader->enable();