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

Mongodb Laravel Package

jenssegers/mongodb

This package brings MongoDB support to Laravel's Eloquent model and query builder, using the original Laravel API and methods so you can keep the same fluent syntax. Formerly jenssegers/mongodb, it is now mongodb/laravel-mongodb and supports Laravel 10.x as a drop-in replacement.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

Primary decision: persistence architecture for the data layer. This package is the deciding lever when we ask "does this workload belong in a document store, or do we stay on Postgres/MySQL?" It lets us answer that per-domain instead of per-application, because a model can move to MongoDB without rewriting controllers, policies, or serialization — the Eloquent contract is preserved.

  • Feature delivery: flexible/nested data without migration pain. Product catalogs with per-category attributes, CMS/content blocks, user preference trees, and event payloads that evolve weekly are poor fits for rigid schemas. Embedded documents (embedsOne/embedsMany, plus new auto-embedding) mean one read instead of four joins. This shortens the "model the domain → ship the feature" loop.
  • Roadmap: polyglot persistence as an option, not a rewrite. Because it plugs into Laravel's database layer, we can introduce MongoDB for one bounded context (e.g., activity feeds, audit logs, notifications) while the transactional core stays relational. That's a much cheaper roadmap bet than a platform migration, and it's reversible.
  • Build vs. buy: buy. The alternative is hand-rolling a repository layer over mongodb/mongodb, or maintaining an abandoned fork. This is now owned by MongoDB, Inc. (renamed from jenssegers/mongodb to mongodb/laravel-mongodb), releases are GPG-signed, and it tracks Laravel's own semantics as the reference implementation. Building this in-house is a multi-quarter maintenance tax for zero differentiation.
  • Consolidation play: one dependency covers several infrastructure slots. GridFS filesystem adapter, cache store, lock driver, queue/batch driver, and a Scout engine (Atlas Search, including relevance _score sorting) ship in the same package. That can retire 2–3 third-party integrations and their security-review surface.
  • Throughput/scaling decisions. High-write, append-heavy surfaces (telemetry, clickstream, job payloads) can be offloaded here without changing our application conventions, deferring a relational sharding project.
  • Operational decisions it unblocks: deciding whether we standardize on MongoDB Atlas (unlocks Atlas Search and Atlas Vector Search) versus self-hosted (replica set required for transactions). The package's feature ceiling is effectively an Atlas decision, so this belongs in the vendor/budget conversation, not just the engineering one.

When to Consider This Package

Adopt when most of these hold:

  • The stack is Laravel and the team is already fluent in Eloquent — the value proposition is zero new mental model, and that only pays off if Eloquent is already the house style.
  • The data is genuinely document-shaped: variable/nested attributes, arrays of sub-documents, or schemas that change faster than a migration cadence can absorb.
  • Read patterns are "fetch the whole aggregate by key" rather than ad-hoc multi-entity joins and aggregation-heavy reporting.
  • We need horizontal write scale, or we're already paying for Atlas and want Search/Vector Search reachable from application code.
  • We want MongoDB to be an option, not a commitment — keeping the relational core intact is a stated constraint.
  • We can pin to a supported matrix: 5.x targets modern Laravel/PHP, and 5.9.0 dropped Laravel 10, 11 and PHP 8.1. Legacy-app adoption is a version-matrix conversation, not a drop-in.

Look elsewhere (or push back) when:

  • Relational integrity is the product. Foreign keys, cascading constraints, and multi-table ACID are not what this gives you. If the domain is money movement, ledgers, entitlements, or inventory, that belongs in the relational store; MongoDB's transactions require a replica set and are a weaker guarantee than a relational engine.
  • Analytics/BI is a core workload. Complex joins, window functions, and warehouse-style reporting are painful here. If BI reads the operational store directly, this is the wrong store.
  • The team has no MongoDB operational experience. Index design, schema modeling (embed vs. reference), and capacity planning are different disciplines. The package removes the code learning curve, not the operations one — and bad document modeling is far more expensive to reverse than a bad table.
  • Migrations and schema governance are a hard requirement. Schema-builder/migration parity with Laravel is not full-fidelity. If audit or compliance requires declarative, reviewable schema diffs, this creates friction. (HasSchemaVersion helps, but it's a pattern, not a governance tool.)
  • The real need is just JSON columns. If we're on Postgres, jsonb plus indexes covers most of the "flexible schema" ask without a second datastore, second backup strategy, and second on-call runbook. Introducing MongoDB only to store JSON is a net negative.
  • Vector search is the driver. 5.9.0 explicitly does not support the base vector-search methods; Atlas Vector Search is reachable through aggregation, not a first-class API. Don't adopt this expecting a RAG/embeddings primitive.
  • Support expectations exceed community norms. Issues live in MongoDB's JIRA (PHPLARA), not GitHub, and general questions route to MongoDB's commercial support channels. Fine for most teams; a gap if we need contractual SLAs without an Atlas agreement.

Two data caveats before this reaches a decision doc: the "0 dependents" figure is a dataset artifact, not a signal — the predecessor package is one of the most-installed Laravel extensions in existence, so treat dependency risk as low and verify via Packagist before quoting numbers. Likewise, the maturity signal here is "README + releases," so the diligence we still owe is our own: a spike on index strategy, a read on the upgrade cadence (frequent minor releases, some with breaking changes — 5.9.0 dropped framework versions), and confirmation that our Laravel/PHP versions are in the supported matrix.

How to Pitch It (Stakeholders)

One-liner for executives: This is the official MongoDB-maintained Eloquent driver for Laravel. It lets us put document-shaped, high-write workloads on MongoDB without retraining the team or rewriting application code — a scoped, reversible bet rather than a platform migration.

What it buys us: faster delivery on features with evolving or nested data (catalogs, content, preferences, event payloads); one read instead of several joins for aggregate-shaped screens; and the ability to introduce MongoDB for a single bounded context while the transactional core stays relational. It also consolidates infrastructure — filesystem, cache, locks, queues, and search all come from the same dependency.

Cost and effort: MIT-licensed, no per-seat cost; the real spend is engineering time (a spike plus one bounded service), plus Atlas if we want Search/Vector Search and managed operations. Incremental cost is meaningfully lower than a relational re-architecture, and the blast radius is one service.

Risk, honestly stated: this is a second datastore — second backup/restore path, second on-call runbook, second set of index and capacity decisions. Transactions are weaker than a relational engine. Migration tooling is not at parity. And it is only cheap if we scope it to data that actually wants to be a document; used as a JSON bucket, it's a net negative versus Postgres jsonb.

What we're asking for: a timeboxed spike on one bounded context with go/no-go criteria agreed up front (read latency, operational effort, and whether the domain's queries stay aggregate-shaped). If those criteria fail, we walk away having spent days, not a quarter — and the relational core is untouched either way.

For engineering: the pull is that it mirrors illuminate/database by design — when behavior diverges, the project aligns to Laravel rather than inventing a MongoDB dialect. Pin the major version, check the compatibility matrix against our Laravel/PHP baseline before committing, and treat document modeling and index design as the real skills gap to close in the spike.

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.
steadrun/laravel-monitor
labyrinthe/connect-laravel
elmogy/layan
drewdan/sentinel-client
dskripchenko/laravel-llm
fatryst/nuonuo
stevenay/myanfont
gmostafa/php-graphql-client
xeviant/paystack
snowsoft/faker
meditationsteps/blogetc
animalyoung/laravel-influxdb
onix-solutions/sms-telera
lonely-lights/prosetta
oxygen/data
oxygen/core
jengo/base
xiloryx/log-collector
a21ns1g4ts/filament-stripe
la-php/laravel-admin