Entity Managers

This document assumes you’ve installed hiraeth/bootstrap or hiraeth/doctrine and hiraeth/cache. If you haven’t your mileage may vary. See the installation docs for more information.

Managers, or more fully “Entity Managers,” are Doctrine’s mechanism for working with model objects or “entities.” Minimally, a manager needs to know what connection it uses and where to find its entity classes. The default manager will use the default connection and look for entities in local/entities.

To change these settings (and more) you can edit config/managers/default.jin. Due to the length of this configuration, it will not be included in full, however, the basic layout looks something like the following:


    connection = default
    cache = default
    paths = ["local/entities"]

Hiraeth’s Doctrine integration supports mulitple managers out of the box, so the preferred way to obtain your manager is to inject the Hiraeth\Doctrine\ManagerRegistry:

use Hiraeth\Doctrine\ManagerRegistry;

class MyService
    public function __construct(ManagerRegistry $registry)
        $this->manager = $registry->getManager('default');