| Recommend this page to a friend! |
| Packages of ?????? ??????? | Adaptive Entity Manager | docs/guides/aem-and-hexagonal-architecture.md | Download |
|
|
||||||||||||||||||||
AEM and hexagonal architectureHow to place Adaptive Entity Manager in a ports and adapters (hexagonal) layout so persistence does not leak into the domain. Idea in one sentenceDomain and application define what to load and persist; AEM lives in infrastructure, behind repository adapters that implement your ports. Layering
Responsibilities| Layer | Owns | Does not own | |-------|------|----------------| | Domain | Invariants, value objects, domain services | SQL, HTTP URLs, table names | | Application | Use cases, orchestration | Adapter choice, metadata YAML | | Infrastructure (AEM) | Metadata, hydration, UnitOfWork, adapters | Business rules | Repository port example
Wire the port in your DI container (Symfony, manual, etc.). The bundle is optional; the pattern is the same with a manually constructed One adapter per data sourceHexagonal style maps cleanly to AEM:
Different bounded contexts can use different adapters while sharing the same AEM patterns. Lazy loading and boundariesAEM supports lazy associations via proxies. Inside aggregate boundaries, prefer explicit loading in the adapter or application service so invariants stay obvious. See AEM and DDD for aggregate-oriented notes. Related guides
Stable targetThe recommended finish line in MIGRATION_ROADMAP.md is stable adaptive persistence: hexagonal boundaries + AEM + adapters?not a mandatory move to Doctrine ORM. |