Docs Menu
Docs Home
/ /

MongoDB PHP Library

The MongoDB PHP Library provides a high-level abstraction around the lower-level mongodb extension.

The mongodb extension provides a limited API to connect to the database and execute generic commands, queries, and write operations. In contrast, the MongoDB PHP Library provides a full-featured API and models client, database, and collection objects. Each of those classes provide various helper methods for performing operations in context. For example, MongoDB\Collection implements methods for executing CRUD operations and managing indexes on the collection, among other things.

If you are developing a PHP application with MongoDB, you should consider using the MongoDB PHP Library instead of the extension alone.

If you have some experience with MongoDB but are new to the PHP library, the following pages should help you get started:

Code examples can be found in the examples directory in the source code.

If you have previously worked with the legacy mongo extension, it will be helpful to review the Legacy Driver Upgrade Guide for a summary of API changes between the old driver and this library.

If you are a new MongoDB user, the following links should help you become more familiar with MongoDB and introduce some of the concepts and terms you will encounter in the library documentation:

Installation →