doctrine/mongodb-odm) as a dependency, adding ~50MB to the footprint.api-platform/core) must already be in use (not a standalone solution).ApiPlatform\Doctrine\Orm\Filter\* filters won’t work with ODM; custom filters may be needed.$lookup, aggregation pipelines) differs from DQL, requiring custom DTOs or GraphQL-like queries for complex joins.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Data Consistency | High | Implement event sourcing or saga pattern for cross-database transactions. Use MongoDB change streams + Symfony Messenger for sync. |
| Query Performance | Medium | Avoid complex joins; use denormalized data or application-side joins. Profile with explain() in MongoDB. |
| Schema Migration | Medium | Use Doctrine Migrations for SQL and custom scripts for MongoDB (no native migration tool). |
| Tooling Gaps | Low | Leverage API Platform’s CLI for SQL schema; use MongoDB Compass or NoSQL tools for ODM. |
| Learning Curve | Medium | Document query differences (e.g., find() vs. createQueryBuilder()) and serialization quirks (e.g., @Groups vs. MongoDB’s dynamic schema). |
Why MongoDB?
Data Model Design
User in PostgreSQL) and NoSQL (e.g., UserProfile in MongoDB) be managed?Query Complexity
Performance SLAs
cache:clear) be handled for hybrid data?Team Expertise
Phase 1: Proof of Concept (2-4 weeks)
api-platform/doctrine-odm and doctrine/mongodb-odm to composer.json.ProductVariant) and expose it via API Platform.Phase 2: Hybrid Data Model (4-8 weeks)
Product) and MongoDB (e.g., ProductVariant).postPersist) to sync data if needed.Phase 3: Full Integration (8+ weeks)
StashDriver for API Platform).| Component | Compatibility Notes |
|---|---|
| API Platform Core | ✅ Full support (resources, serialization, validation). |
| Doctrine ORM | ⚠️ No direct integration; treat as separate data sources. |
| Symfony Validator | ✅ Works for MongoDB entities (same as ORM). |
| Doctrine Migrations | ❌ No native support; use custom scripts or MongoDB Migration Tool. |
| API Platform Filters | ❌ ORM-specific filters won’t work; use custom filters or GraphQL. |
| Cache (APCu, Redis) | ✅ Works, but cache invalidation must account for both SQL/NoSQL changes. |
ApiResource annotations; no need to rewrite controllers.ext-mongodb) and PHP extensions (e.g., php-mongodb).make:entity won’t work for ODM; use custom commands or **ODM’s php app/console doctrine:mongoDB:schema:update).How can I help you explore Laravel packages today?