Weave 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

Laravel Mongodb Laravel Package

mongodb/laravel-mongodb

Laravel MongoDB adds MongoDB support to Laravel's Eloquent models and query builder while preserving the familiar Laravel API. Maintained by MongoDB, it works with Laravel 10.x and lets you use existing Eloquent methods with MongoDB.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Verdict: Mature, vendor-owned, production-credible. The decision is not "is this package good" — it is "does a document store fit the bounded context we are about to move," plus a version-matrix trap that has to be resolved before any commitment.

Architecture fit

  • Core value prop: the package subclasses Eloquent and the query builder rather than introducing a repository abstraction, so a model can be repointed at MongoDB without rewriting controller or service code. That is a materially lower integration cost than bolting on a second ORM or adopting a new data-access layer, and it is the single strongest architectural argument in its favour.
  • Best-fit workloads: schema-variable or rapidly-evolving entities (catalogs, CMS/content, product attributes), high-write ingestion and event/audit logs, embedded aggregates that would otherwise need 4–6 SQL joins, and the ancillary tiers — cache, session, queue, lock, GridFS filesystem — where the package already ships first-party drivers (cache/lock in 4.3, GridFS in 4.5, batch queue in 4.4).
  • Poor-fit workloads: anything requiring cross-entity ACID transactions, foreign-key-enforced integrity, or heavy ad-hoc relational reporting. Document modelling replaces joins with embedding and denormalisation; that is a permanent design commitment, not a configuration choice.
  • Hybrid is the realistic target architecture: MySQL/Postgres remains the transactional system of record; MongoDB takes one bounded context plus the ancillary drivers. Cross-connection Eloquent relations are supported, so this is viable, but the seam must be explicitly designed — dual writes are the failure mode to guard against.

Integration feasibility

  • Two dependencies, not one: composer require mongodb/laravel-mongodb plus the ext-mongodb PHP extension (and mongodb/mongodb underneath). The extension is a base-image/CI buildpack change — it cannot be satisfied by composer alone. This is the most common reason adoption stalls inside platform-constrained orgs.
  • Configuration surface is small: a mongodb connection in config/database.php, models extending the package base class (or the DocumentModel trait from 4.6 to reuse an existing model). A working spike is a 1–2 day exercise; production readiness is 3–6 weeks, dominated by schema/index design, test harness, and environment provisioning rather than code.
  • Feature parity is broader than expected: aggregation pipeline builder, collection name prefixes, HasSchemaVersion for schema versioning, BSON casts, Scout engine integration, and Laravel Boost tooling/agent skills. This reduces the "we'll have to build a lot ourselves" risk considerably.
  • Feasible, but validate parity on your actual query surface — see key questions.

Technical risk

Risk Severity Notes
Laravel version treadmill High v5.9 dropped Laravel 10, 11 and PHP 8.1 outright. Teams on Laravel 10/11 are capped at the v4.x line and receive no new features. This must be a planning input, not a surprise at upgrade time.
Semantic parity illusion High "Uses exactly the same methods" is API parity, not behaviour parity. Joins and parts of the schema builder are out of scope; LIKE→regex, null-vs-missing-field, array matching, groupBy semantics, and case-insensitive collation all diverge. Budget a query-surface audit.
Loss of referential integrity Medium-High No foreign keys, no cascades. Orphans and dangling refs become an application-level obligation.
Transaction topology dependency Medium Multi-document transactions require a replica set or sharded cluster. A standalone local dev instance silently cannot do what staging does.
Extension/runtime coupling Medium ext-mongodb 1.x vs 2.x, PHP minor-version ABI, and image rebuilds on every upgrade.
Ecosystem/tooling friction Low-Medium Packages that emit raw SQL or assume joins (reporting tools, admin panels, some BI connectors) will not carry over.

Mitigating signals are genuinely strong: MongoDB, Inc. owns the package (renamed from jenssegers/mongodb), releases are automated and GPG-signed, SBOM and PHPStan/code-scanning artifacts are published, and there is a documented security-vulnerability channel. Supply-chain posture is better than most OSS in this ecosystem. Note the metadata oddity — "Dependents: 0" contradicts 7k stars and Packagist reality and is a scoring artifact; do not let it suppress the score. The opportunity: 48.69 reads correctly as "mature, table-stakes, low novelty" rather than "weak."

Key questions

  1. Which Laravel and PHP versions are we pinned to today, and does that put us on v5.x or strand us on v4.x?
  2. Can we modify base images / CI to install ext-mongodb, or is the runtime managed and immutable?
  3. Which bounded context actually moves, and does it require multi-document transactions or cross-entity consistency?
  4. Do we run Atlas or self-hosted? Replica set availability in dev/staging, and the cost model?
  5. Legal: MIT covers the driver; the MongoDB server is SSPL. Confirm that is acceptable for our deployment and any resale/SaaS-exposure scenario.
  6. What is the query-surface inventory that must be validated for parity (joins, aggregates, LIKE, groupBy, pagination)?
  7. Who owns document schema evolution — is HasSchemaVersion adopted as policy or ignored?

Integration Approach

Stack fit

  • Supported matrix: Laravel 12+ and PHP 8.2+ on the v5.x line; Laravel 10/11 on v4.x (4.6+ for DocumentModel and HasSchemaVersion). MongoDB server 6.0+/7.0/8.0 across standalone, replica set and sharded cluster — the project explicitly tests all topologies, which is a meaningful assurance for regulated environments.
  • Strong fit where the app is conventional Laravel: Eloquent models, service container, queue/cache/session abstractions, Laravel Scout search. The package slots into existing abstractions rather than competing with them.
  • Weak fit where the app is SQL-shaped: raw query fragments, DB::table(...)->join(...), reporting layers, or anything relying on migrations as the schema contract.

Migration path

Three paths, in ascending risk — and they can be layered:

  1. Ancillary-first (recommended entry point). Move cache, session, queue, and locks to the mongodb drivers. Zero data-model change, immediate operational learning, reversible by config. Note: this couples application availability to the database — only do it if the cluster's SLA exceeds the current cache tier's.
  2. Strangler on one bounded context. New collection, new model, dual-read/compare in staging, then cut writes. No cross-store transaction; design an outbox or accept eventual consistency at the seam.
  3. Greenfield service. Lowest friction, cleanest document model, no migration tooling required. Preferred if the roadmap permits.

Avoid: a wholesale ORM swap of an existing relational core. The joins, migrations, and FK assumptions do not survive translation, and the effort is unbounded.

Compatibility

  • Pin the major version explicitly and record the Laravel/PHP ceiling it implies in the tech-radar. A floating ^5.0 constraint that silently raises the Laravel floor is the most likely upgrade incident.
  • Run the package's supported PHP matrix in CI with ext-mongodb installed; add a container with a single-node replica set so transaction tests are exercisable locally.
  • Track illuminate/database alignment — the package follows Laravel, not the reverse, so Laravel upgrades must be sequenced after confirming a compatible package release.

Sequencing

Phase Scope Duration Exit criteria
0 Spike: extension in image, connection, one model, CRUD + aggregation, replica-set CI 1–2 wks Parity audit of our query surface complete
1 Ancillary drivers (cache/session/queue) in staging 1–2 wks Load test + failover drill pass
2 First bounded context, read-only shadow traffic 3–4 wks Document model reviewed; index plan agreed
3 Cut writes, decommission old path 2 wks Rollback rehearsal executed
4 Second context / expansion ongoing Runbook and ownership settled

Operational Impact

Maintenance

  • Upgrade cadence is fast and non-negotiable. Multiple minor and patch releases per quarter, with Laravel/PHP support drops landing in minors (5.9 is the precedent). Budget ~1 engineer-week per quarter for tracking plus one planned upgrade per year.
  • Three upgrade surfaces to coordinate: the package, ext-mongodb, and the MongoDB server. They version independently, which is the main ongoing toil.
  • Positive: automated, signed releases with SBOM and static-analysis artifacts mean the audit trail for a security review already exists — a real reduction in compliance effort compared with typical OSS.

Support

  • Commercial backing via MongoDB's support channels; issues are tracked in JIRA (PHPLARA), not GitHub Issues. GitHub Issues is not the intake path — teams expecting GitHub-native triage will find the workflow unfamiliar, and community visibility is lower than the star count implies. JIRA accounts are required to report or follow bugs.
  • Documentation lives on mongodb.com, not the repo, and is versioned separately — pin doc links to the package major version in internal runbooks.
  • No first-party SLA under MIT. If this becomes system-of-record for a revenue path, price an Atlas/support contract rather than relying on community response.

Scaling

  • Horizontal scale is a genuine strength: sharding, read preference, and replica-set reads are first-party and tested. Read scaling with secondary reads trades consistency — document that trade-off per query path.
  • Connection management is the under-appreciated constraint. Under php-fpm, each worker holds its own pooled connections; worker count × pool size sets the ceiling on the cluster's connection budget. This is the most likely surprise scaling incident, and it is invisible until concurrency ramps.
  • Index design replaces schema design as the performance lever. Compound indexes, ESR ordering, and aggregation pipeline shape are the tuning surface; the team's SQL index intuition transfers only partially.

Failure modes

  • Database becomes a single point of failure for cache, session, queue and locks simultaneously if the ancillary-first path is taken. Previously, a cache outage degraded performance; now it may take auth and sessions down. Mitigate with a separate cluster or a fallback driver.
  • Connection storms / pool exhaustion at worker-count increases — surfaces as latency, not errors.
  • Transient transaction and retryable-write errors under replica-set failover; application code must be idempotent. Upsert races produce duplicate-key errors that SQL teams do not expect.
  • Silent orphaned references accumulate without FK enforcement — needs a scheduled integrity job.
  • Behavioural divergence bugs (null vs missing, regex LIKE, groupBy edge cases) are the hardest to catch: they pass tests written against SQL expectations. The groupBy/_id fix in 5.9 and the MongoLock expired-lock pruning fix in 5.9 are recent examples of correctness issues in exactly these seams — evidence that pinning to the latest patch matters.

Ramp-up

  • Engineers: the API is familiar, the modelling is not. Embedding vs referencing, denormalisation, and index-first design require deliberate training — plan 2–4 sprints of reduced velocity on the first context, and do not staff it with the team's most junior backend engineers.
  • Platform/SRE: new runbook content — replica-set health, backup/restore verification, index build impact, connection-budget monitoring, failover drills.
  • Organisation: clear data-ownership split between the SQL system of record and the document store, plus a written policy on schema versioning (HasSchemaVersion) so collections don't drift.

Recommendation: approve as a targeted, bounded adoption — ancillary drivers first, then one document-shaped bounded context — with the Laravel/PHP ceiling resolved and the query-parity audit completed as gate conditions before Phase 2. Do not approve a wholesale replacement of the relational core.

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.
coleus/frame
thtg88/journalism
filagora/filagora-ai-forums
rlacerda83/query-parser
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings