whatisgithub

What is laravel-mongodb?

mongodb/laravel-mongodb — explained in plain English

Analysis updated 2026-06-22

7,079PHPAudience · developerComplexity · 3/5Setup · moderate

In one sentence

A Laravel package that lets you use MongoDB as your database with the exact same Eloquent model and query syntax you already know, no new commands to learn.

Mindmap

mindmap
  root((laravel-mongodb))
    What it does
      MongoDB for Laravel
      Eloquent extension
      Same query syntax
    Tech Stack
      PHP
      Laravel
      MongoDB
    Use Cases
      Flexible data storage
      Mixed databases
      Document models
    Setup
      Install package
      Configure connection
      See MongoDB docs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Add MongoDB as a database to an existing Laravel 10+ application without rewriting any Eloquent query logic.

USE CASE 2

Build a Laravel app that stores flexible, variable-structure documents instead of fixed-column relational tables.

USE CASE 3

Migrate a Laravel project from MySQL to MongoDB while keeping the same model and controller code intact.

What is it built with?

PHPLaravelMongoDB

How does it compare?

mongodb/laravel-mongodbmoodle/moodlethe-benchmarker/web-frameworks
Stars7,0797,0797,085
LanguagePHPPHPPHP
Setup difficultymoderatehardhard
Complexity3/54/53/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

Requires a running MongoDB instance and a Laravel 10 or newer project.

So what is it?

Laravel is a popular PHP framework for building websites and web applications. It comes with a built-in system for talking to databases called Eloquent, which lets developers write database queries in a clean, readable style without writing raw SQL. By default, Eloquent works with traditional databases like MySQL and PostgreSQL. MongoDB is a different kind of database. Instead of organizing data into tables with fixed columns, it stores data as flexible documents, similar to JSON objects. This makes it a good fit for data that varies in structure from one record to the next. This package bridges those two worlds. It extends Laravel's Eloquent model and query builder so that developers can work with MongoDB using the exact same patterns and method names they already know from working with standard databases. The goal is to make switching to or adding MongoDB feel as natural as possible for a Laravel developer, without having to learn a completely different set of commands. The package is now officially maintained by MongoDB, Inc., which took over ownership from its original creator. It supports Laravel 10 and newer versions. For projects still running older versions of Laravel, earlier releases of the package remain available on GitHub. The README is sparse on setup details and points to the official MongoDB documentation site for full installation and usage guides. Bug reports are handled through MongoDB's JIRA issue tracker rather than GitHub issues. Security vulnerabilities have their own separate reporting process documented on the MongoDB website.

Copy-paste prompts

Prompt 1
Add laravel-mongodb to my Laravel 11 app and show me how to define an Eloquent model that reads and writes to a MongoDB collection.
Prompt 2
How do I write a Laravel Eloquent query with laravel-mongodb to find documents where a nested field matches a specific value?
Prompt 3
My Laravel app uses MySQL for most tables but I want one collection in MongoDB, how do I configure laravel-mongodb to use both databases at once?
Prompt 4
How do I handle embedded relationships like embeds-many and embeds-one in a Laravel model using laravel-mongodb?

Frequently asked questions

What is laravel-mongodb?

A Laravel package that lets you use MongoDB as your database with the exact same Eloquent model and query syntax you already know, no new commands to learn.

What language is laravel-mongodb written in?

Mainly PHP. The stack also includes PHP, Laravel, MongoDB.

How hard is laravel-mongodb to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is laravel-mongodb for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.