Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Mirror Bundle Laravel Package

desarrolla2/doctrine-mirror-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Use Case Alignment: The bundle appears to aim at database mirroring/duplication (e.g., replicating Doctrine entities to a secondary schema/table for reporting, caching, or audit purposes). This could fit niche use cases like:
    • Shadow databases for analytics without impacting OLTP.
    • Temporal data storage (e.g., soft-deletes mirrored to a separate table).
    • Multi-tenancy isolation via mirrored schemas.
  • Laravel/Doctrine Synergy: Laravel’s Eloquent is not natively Doctrine-ORM, but if the app already uses Doctrine (e.g., via doctrine/dbal or doctrine/orm for hybrid stacks), this could integrate. For pure Eloquent apps, zero fit without heavy refactoring.
  • Anti-Pattern Risk: Mirroring adds write amplification (every write triggers two operations) and eventual consistency challenges. Assess if the use case justifies complexity.

Integration Feasibility

  • Doctrine Dependency: Requires Doctrine ORM (not Eloquent). If the app uses:
    • doctrine/dbal + custom repositories: Medium effort (adapt to ORM).
    • Pure Eloquent: High effort (rewrite entity mappings or proxy writes).
  • Symfony Bundle: Designed for Symfony, but Laravel can load Symfony bundles via symfony/flex or humbucker/symfony-bundle. Compatibility unknown without testing.
  • Event System: Likely hooks into Doctrine’s lifecycle events (e.g., prePersist, postUpdate). Laravel’s Eloquent events (saving, saved) would need translation.

Technical Risk

  • Abandoned Project: Last release 2017, no dependents, and "Not ready yet" warning. High risk of breakage or unsupported Doctrine/Symfony versions.
  • Performance Overhead: Mirroring introduces:
    • Double writes (OLTP + mirror).
    • Transaction boundaries (must handle rollbacks in both).
    • Schema drift if mirror schema evolves separately.
  • Testing Gap: No tests, no CI, no community. Manual validation required for edge cases (e.g., nested entities, inheritance).

Key Questions

  1. Why Mirror?
    • Is this for read scaling, audit trails, or data isolation? Could alternatives (e.g., Laravel’s replicas, read models, or event sourcing) suffice?
  2. Doctrine Commitment:
    • Is the app already using Doctrine ORM, or would this require a major migration from Eloquent?
  3. Schema Management:
    • How will mirror schema be kept in sync with the primary? (Manual migrations? Custom scripts?)
  4. Failure Modes:
    • What happens if the mirror fails? Will writes to the primary block until mirror recovers?
  5. Alternatives:
    • For Laravel, consider:
      • Database triggers (native or via doctrine/dbal).
      • Queue-based replication (e.g., publish entity changes to a queue, consume to mirror).
      • Read replicas (if using PostgreSQL/MySQL).
      • Laravel packages like spatie/laravel-activitylog (for audit trails).

Integration Approach

Stack Fit

Component Fit Level Notes
Laravel Core ❌ Poor Bundle targets Symfony/Doctrine ORM; Eloquent apps need translation.
Doctrine ORM ✅ Excellent Native fit if already using ORM.
Symfony Bundle ⚠️ Conditional Requires humbucker/symfony-bundle or manual Symfony loader setup.
Database ✅ Flexible Works with any Doctrine-supported DB (MySQL, PostgreSQL, etc.).

Migration Path

  1. Assess Doctrine Usage:
    • If not using Doctrine ORM, evaluate cost of migration vs. alternatives (e.g., database triggers).
  2. Symfony Bundle Integration:
    • Install via Composer:
      composer require desarrolla2/doctrine-mirror-bundle
      
    • Load the bundle in Laravel’s config/app.php (if using Symfony loader) or via service provider.
  3. Entity Configuration:
    • Annotate entities with mirroring rules (e.g., @Mirror(target="mirror_schema.entity")).
    • Example:
      use Desarrolla2\DoctrineMirrorBundle\Annotation\Mirror;
      /**
       * @Mirror(target="audit.user")
       */
      class User {}
      
  4. Event Listeners:
    • Override Doctrine events to handle mirror writes (if bundle doesn’t auto-hook).
  5. Testing:
    • Validate mirror consistency with:
      • Unit tests for entity lifecycle events.
      • Integration tests for write/read consistency.

Compatibility

  • Doctrine Version: Bundle likely targets Doctrine ORM <2.7 (2017 release). Check for conflicts with Laravel’s doctrine/dbal (~1.4).
  • PHP Version: May require PHP 5.6–7.0 (common in 2017). Test with Laravel’s PHP version.
  • Symfony Dependencies: Could pull in outdated Symfony components (e.g., symfony/dependency-injection:3.x). Use composer why-not to audit.

Sequencing

  1. Phase 1: Proof of Concept
    • Mirror a single non-critical entity (e.g., Log table).
    • Test writes/reads under load.
  2. Phase 2: Critical Path
    • Mirror core entities (e.g., User, Order).
    • Implement rollback handling (e.g., mirror fails → primary write fails).
  3. Phase 3: Observability
    • Add metrics for mirror lag (e.g., mirror_last_updated_at column).
    • Alert on consistency drift.

Operational Impact

Maintenance

  • Bundle Maintenance: Zero support (abandoned project). Any fixes require forking.
  • Schema Drift:
    • Mirror schema must be manually updated if primary schema changes.
    • Risk of silent failures if migrations are missed.
  • Dependency Bloat:
    • Pulls in Symfony components, increasing attack surface.

Support

  • Debugging:
    • No logs, no docs. Debugging mirror failures will require deep Doctrine event inspection.
    • Example issues:
      • "Mirror write failed: Deadlock" → Need to handle retries.
      • "Entity not mirrored: Unknown target" → Schema mismatch.
  • Vendor Lock-in:
    • Custom mirroring logic may be hard to replace if bundle is deprecated.

Scaling

  • Write Scaling:
    • Negative impact: Every write hits two databases (OLTP + mirror).
    • Mitigation:
      • Use asynchronous mirroring (e.g., queue writes to mirror).
      • Offload mirror to a separate service (e.g., Kafka + consumer).
  • Read Scaling:
    • Mirror can offload reads from primary, but:
      • Eventual consistency means stale data possible.
      • Requires client-side merge logic if strong consistency is needed.
  • Database Load:
    • Mirror DB may become a bottleneck if queries are complex.

Failure Modes

Failure Scenario Impact Mitigation Strategy
Mirror DB down Primary writes blocked Implement circuit breaker (fail open).
Schema mismatch Mirror writes fail silently Pre-deploy schema validation.
Network partition (OLTP ↔ Mirror) Inconsistent data Use transactional outbox pattern.
Doctrine event listener crash Mirror lag Supervisor + retry queue.
Primary DB failover Mirror out of sync Replication from primary’s replica.

Ramp-Up

  • Learning Curve:
    • High for teams unfamiliar with:
      • Doctrine ORM events.
      • Symfony bundles in Laravel.
      • Mirroring patterns (e.g., handling cascades, inheritance).
  • Onboarding Steps:
    1. Doctrine Training: Ensure team understands ORM lifecycle events.
    2. Bundle Forking: Prepare to fork if issues arise.
    3. Chaos Testing: Simulate mirror failures to validate recovery.
  • Documentation Gap:
    • No README, no wiki. Expect trial-and-error for setup.
    • Workaround: Study Symfony bundle docs and adapt.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony