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 Readonly Middleware Laravel Package

dnwk/doctrine-readonly-middleware

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Database Read Scaling: Enables seamless integration with read replicas or dedicated read-only databases, reducing load on primary DBs and improving performance for read-heavy applications.
  • Testing & CI/CD: Facilitates testing database read operations in isolation, ensuring consistency across environments (dev/staging/prod) without risking write operations.
  • Security & Compliance: Supports strict read-only modes for audit logs, reporting, or analytics systems where writes are prohibited by policy.
  • Multi-Tenant Architecture: Simplifies routing read requests to tenant-specific replicas while maintaining a single write connection.
  • Cost Optimization: Reduces cloud database costs by offloading read traffic to cheaper, read-only instances (e.g., Aurora Serverless v11g).
  • Build vs. Buy: Avoids custom middleware development for read-only routing, leveraging a lightweight, Doctrine-compatible solution.

When to Consider This Package

  • Adopt if:

    • Your app uses Doctrine ORM and needs read-only database connections for scaling, testing, or compliance.
    • You require a simple, declarative way to toggle read-only mode without complex configuration.
    • Your team prioritizes experimental but low-risk solutions (MIT license, minimal dependencies).
    • You’re using PHP/Laravel and want to avoid reinventing middleware for read replicas.
  • Look elsewhere if:

    • You need production-grade reliability (package is experimental; test thoroughly).
    • Your stack uses non-Doctrine databases (e.g., Eloquent, raw PDO).
    • You require dynamic routing (e.g., per-request read/write splitting) beyond a global toggle.
    • Your use case demands advanced features like connection pooling or failover logic (consider doctrine/dbal extensions or custom middleware).
    • You’re constrained by enterprise support (no dependents or maintainer activity).

How to Pitch It (Stakeholders)

For Executives:

"This package lets us scale read operations efficiently by routing queries to read-only databases or replicas—reducing primary DB load and cutting costs. For example, analytics dashboards or audit logs could run on dedicated read instances without risking data corruption. It’s a low-effort, high-impact way to improve performance and reliability, especially for read-heavy workloads. Since it’s experimental, we’d validate it in staging first, but the MIT license and Doctrine integration make it a safe bet for PHP/Laravel apps."

For Engineering:

*"The dnwk/doctrine-readonly-middleware provides a one-liner (ReadonlyMiddleware::enable()) to force Doctrine to use read-only connections. Key benefits:

  • Simplicity: No need to manage multiple DB configs or proxies.
  • Testing: Perfect for CI/CD to simulate read-only environments.
  • Compatibility: Works with Doctrine ORM (tested with Laravel via Eloquent’s Doctrine bridge).
  • Limitations: Experimental—validate edge cases (e.g., transactions, nested queries). If we need more control later, we can extend it or switch to a custom solution.

Proposal: Pilot this for our reporting service’s read replicas and measure DB load reduction. If successful, roll it out to other read-heavy modules."*

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.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours