PHP Classes

File: docs/rfc/RFC-004-optional-doctrine-orm-exit-path.md

Recommend this page to a friend!
  Packages of ?????? ???????   Adaptive Entity Manager   docs/rfc/RFC-004-optional-doctrine-orm-exit-path.md   Download  
File: docs/rfc/RFC-004-optional-doctrine-orm-exit-path.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: Adaptive Entity Manager
Entity manager to work with multiple data sources
Author: By
Last change:
Date: 3 months ago
Size: 4,030 bytes
 

 

Contents

Class file image Download

RFC-004: Optional Doctrine ORM exit path (adopter guidance)

| Field | Value | |-------|--------| | Status | Proposed ? aspirational / adopter-only (not core product backlog) | | Date | 2026-05-05 | | Author | Ruslan Kabirov | | Audience | Teams using AEM who choose to migrate a bounded context to Doctrine ORM |

Motivation

Older project materials sometimes described AEM as a bridge toward Doctrine ORM and DQL. That narrative does not match how AEM is positioned today:

  • AEM is an adaptive persistence mapper for legacy databases, mixed sources, and hexagonal architectures.
  • AEM is not a Doctrine ORM replacement, and the core library does not plan to add DQL or a query language.

Some adopters will still voluntarily move a single relational bounded context to Doctrine ORM when their constraints change. This RFC documents that optional exit path so it is not confused with AEM?s product roadmap or with MIGRATION_ROADMAP.md (whose recommended finish line is stable AEM + adapters).

When staying on AEM is the right default

  • Multiple data sources (legacy DB + APIs + files) behind different adapters
  • Schemas that are awkward for ORM entity mapping but workable with metadata + adapters
  • Team relies on DBAL/SQL and explicit adapters rather than a unified ORM model
  • Hexagonal layout with repositories as ports and AEM in infrastructure

When an optional Doctrine ORM migration may make sense

  • One bounded context converges on a single relational database you will run for years
  • The team?s standard stack is Doctrine ORM (entities, migrations, bundles, community tooling)
  • You accept the cost of entity mapping, schema ownership, and training
  • Complex read models are a good fit for DQL or the ORM query API in that context only

What this RFC does not propose

  • Adding DQL, QueryBuilder, or ORM-style mapping to kabiroman/adaptive-entity-manager
  • Requiring all AEM users to migrate to Doctrine
  • Replacing MIGRATION_ROADMAP.md Stage 4 with ?Doctrine only?

Optional exit path (sketch)

  1. Freeze the bounded context on AEM (tests, metadata, adapters documented).
  2. Model entities and associations in Doctrine for that database only.
  3. Dual-write or dual-read during cutover if data safety requires it.
  4. Retire the AEM adapter for that context; keep AEM for other sources if needed.
  5. Run complex reads via Doctrine?s APIs where appropriate?for example DQL:
// Example: optional Doctrine ORM read model after cutover (not AEM API)
$query = $doctrineEm->createQuery('
    SELECT u, p, o FROM App\Entity\User u
    JOIN u.profile p
    JOIN u.orders o
    WHERE u.isActive = true
');
$users = $query->getResult();

  1. Document the decision in your own ADR; link back to this RFC only as background.

Relationship to AEM core work

| Topic | AEM core | This RFC | |-------|----------|----------| | EntityDataAdapter | Yes | Adopter implements until cutover | | Domain VO metadata (RFC-003) | Yes | Re-map in Doctrine mapping if you migrate | | DQL / ORM query layer | Out of scope | Adopter uses Doctrine ORM directly | | MIGRATION_ROADMAP.md | Recommended target: stable AEM | Optional branch only |

Alternatives to full ORM cutover

  • Stay on AEM permanently for the context (recommended default in the migration roadmap).
  • DBAL only for reporting SQL without adopting ORM entities.
  • Read models (projections, CQRS) fed by events while writes stay on AEM.

Recommendation

Treat Doctrine ORM and DQL as one optional adoption outcome, documented here for clarity?not as the implied destination of AEM or of the public migration roadmap. Prefer MIGRATION_ROADMAP.md for the supported narrative: legacy ? AEM ? hybrid ? stable adaptive persistence.