Overview
The PHP ecosystem offers several ways to work with MongoDB beyond the core driver. When selecting a library or framework integration, consider the following guidelines:
To use MongoDB in a Laravel application, use the official Laravel MongoDB integration.
To map PHP objects to MongoDB documents with additional features such as relationships, a document manager that persists changes in bulk, and an event system, use Doctrine MongoDB ODM.
To integrate MongoDB with a PHP web framework, choose an integration from the Web Framework Integrations section.
To address specific needs such as caching, messaging, and profiling, choose a tool from the Application Tools section.
Note
Community Maintenance
Except when noted, the libraries and tools on this page are maintained by the community, not by MongoDB. Before using a library, review its repository to confirm it's actively maintained and compatible with your MongoDB and PHP versions.
Libraries and ODMs
Use the following general purpose libraries and object-document mappers (ODMs) to map PHP objects to MongoDB documents:
ODM | Description | Learn More |
|---|---|---|
Laravel MongoDB | MongoDB maintains this official integration for Laravel, which lets you use Laravel Eloquent and Query Builder syntax to store and retrieve MongoDB data. | Laravel MongoDB documentation |
Doctrine MongoDB ODM | Doctrine MongoDB ODM documentation | |
Mongolid | This community-maintained ODM implements the ActiveRecord and DataMapper design patterns and supports embedded and referenced documents. You can use the standalone library or integrate it with Laravel. | Mongolid documentation |
Xenus | This community-maintained ODM supports events, relationships,
and embedded documents. You can use the standalone library or
integrate it with Laravel. | Xenus documentation |
Web Framework Integrations
Use the following integrations to integrate MongoDB in PHP web frameworks:
Web Framework | Description | Learn More |
|---|---|---|
Drupal | A content management system that supports MongoDB, allowing you to store Drupal site data in MongoDB instead of the default SQL database. | Integrate MongoDB with Drupal tutorial |
Laravel MongoDB | An official MongoDB-maintained integration for Laravel, which allows you use MongoDB in a Laravel web application. | Laravel MongoDB documentation |
Symfony | A PHP web framework that offers several ways to integrate MongoDB into Symfony, including the following:
| Symfony MongoDB Integration tutorial |
Yii 2 | A component-based PHP web framework that includes a MongoDB extension. | MongoDB Extension for Yii 2 documentation |
Application Tools
To use MongoDB for a specific function in your PHP application, use one of the following tools:
Tool | Description | Learn More |
|---|---|---|
LLPhant | A generative AI framework that uses MongoDB as a vector store, letting you build AI-powered applications that use semantic search and vector operations with Voyage AI embeddings. | Integrate MongoDB with LLPhant tutorial |
PHPfastcache | A high-performance backend cache system. Use its MongoDB extension to configure MongoDB as a cache pool for your application. | |
Enqueue | A messaging solution that can use MongoDB as the message queue broker. This tool provides a standardized interface for programs to create, send, and read messages. | |
XHGui | A web interface for the XHProf profiler that stores profiling data in MongoDB by default. | XHGui GitHub repository |
PHP Cache | A PSR-6 cache implementation that includes a MongoDB adapter. | PHP Cache documentation |
Flysystem GridFS Adapter | An adapter that allows you to interact with MongoDB GridFS by using Flysystem. | MongoDB GridFS Adapter documentation |
Mongo PHP Adapter | An adapter between applications that rely on the legacy | Mongo PHP Adapter GitHub repository |