Symfony Integration
For an application that uses symfony/dependency-injection, resources/config/orm-services.yaml defines these services:
| Service | Notes |
|---|---|
EntityManagerFactoryInterface and ConnectionParametersFactoryInterface |
Registered directly with their implementations. An application replaces a factory under its interface ID |
Doctrine\ORM\EntityManagerInterface |
Created by the factory of the entity manager, from the parameters derafu.orm.doctrine.dbal and derafu.orm.doctrine.orm |
Derafu\Repository\Contract\RepositoryFactoryInterface $doctrine |
Uses DoctrineRepositoryFactory; tag it for the mapped entities exposed through the repository manager. See repositories |
| The provider of the translations of the package | Tagged derafu_translation.resource_provider |
Import it from the file of services of the application and set the parameters:
imports:
- { resource: '../vendor/derafu/orm/resources/config/orm-services.yaml' }
parameters:
derafu.orm.doctrine.dbal:
url: '%env(DATABASE_URL)%'
derafu.orm.doctrine.orm:
paths: ['%kernel.project_dir%/src/Entity']
naming_strategy: Doctrine\ORM\Mapping\UnderscoreNamingStrategy
Their defaults are a SQLite file in var/app.db and the entities in src/Entity. An application can ignore the file and define its own services, with its own configuration or with Doctrine directly.
The factory still accepts the dbal and orm sections; only the container’s
parameter names include the derafu.orm.doctrine prefix. The configuration does
not register aliases for the concrete factories or Doctrine\ORM\EntityManager.
Consumers inject Doctrine\ORM\EntityManagerInterface.
Repository’s unqualified RepositoryFactoryInterface remains its default
factory for data-provider sources. ORM’s qualified $doctrine factory coexists
with it; importing ORM does not select Doctrine for every repository.