This version of the documentation is archived and no longer supported. To learn how to upgrade your version of PHP Library Manual, refer to the upgrade documentation.

MongoDB PHP Library

The MongoDB PHP Library provides a high-level abstraction around the lower-level PHP driver, also known as the 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.

New to the PHP Library?

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

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

New to MongoDB?

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: