PHPackages                             dittto/doctrine-entity-factories - 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. [Database &amp; ORM](/categories/database)
4. /
5. dittto/doctrine-entity-factories

ActiveLibrary[Database &amp; ORM](/categories/database)

dittto/doctrine-entity-factories
================================

Allows doctrine to pull entities from factories instead of just reflection

1.0.1(8y ago)36.3k3[3 PRs](https://github.com/dittto/doctrine-entity-factories/pulls)MITPHP

Since Aug 21Pushed 6y agoCompare

[ Source](https://github.com/dittto/doctrine-entity-factories)[ Packagist](https://packagist.org/packages/dittto/doctrine-entity-factories)[ RSS](/packages/dittto-doctrine-entity-factories/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (6)Versions (5)Used By (0)

Entity factories for Doctrine
=============================

[](#entity-factories-for-doctrine)

With it's usage of simple PHP objects for entities, Doctrine is a very easy-to-use ORM. It instantiates these entities using reflection. If you want to use entities that rely on another object via dependency injection, however, then you're stuck with setter injection.

This code allows you to pull new entities from a factory instead, allowing constructor injection and cleaner code.

How to use
----------

[](#how-to-use)

First up, install this plugin.

```
composer require dittto/doctrine-entity-factories
```

Next, let's create a factory for our entity. These needs to implement `EntityFactoryInterface`.

```
