Docs Menu
Docs Home
/ /

MongoDB PHP Library

On this page

  • Overview
  • Get Started
  • Connect to MongoDB
  • Databases and Collections
  • Read Data from MongoDB
  • Write Data to MongoDB
  • Specify How CRUD Operations Run on Replica Sets
  • Run a Database Command
  • Transform Your Data with Aggregation
  • Optimize Queries with Indexes
  • Monitoring
  • Secure Your Data
  • Specialized Data Formats
  • Compatibility
  • What's New
  • Upgrade Library Versions
  • FAQ

Welcome to the documentation site for the official MongoDB PHP Library.

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

The mongodb extension provides a limited API to connect to a MongoDB database and execute generic commands, queries, and write operations. In contrast, the PHP library provides a full-featured API and models client, database, and collection objects. If you are developing a PHP application with MongoDB, consider using the PHP library instead of the extension alone.

Learn how to install the library and extension, establish a connection to MongoDB, and begin working with data in the Get Started with the PHP Library tutorial.

Learn how to create and configure a connection to a MongoDB deployment in the Connect to MongoDB section.

Learn how to use the PHP library to work with MongoDB databases and collections in the Databases and Collections section.

Learn how you can retrieve data from MongoDB in the Read Data from MongoDB section.

Learn how you can write data to MongoDB in the Write Data to MongoDB section.

Learn how to configure settings for read and write operations on replica sets in the Specify How CRUD Operations Run on Replica Sets section.

Learn how to run a database command in the Run a Database Command section.

Learn how to use the PHP library to perform aggregation operations in the Transform Your Data with Aggregation section.

Learn how to work with common types of indexes in the Optimize Queries by Using Indexes section.

Learn how to monitor change events in the Monitor Your Application section.

Learn about ways you can authenticate your application and encrypt your data in the Secure Your Data section.

Learn how to work with specialized data formats and custom types in the Specialized Data Formats section.

See compatibility tables showing the recommended PHP library version to use for specific PHP and MongoDB Server versions in the Compatibility section.

Learn about new features and changes in each version in the What's New section.

Learn what changes you must make to your application to upgrade library and extension versions in the Upgrade Library Versions section.

See answers to commonly asked questions about the PHP library in the the Frequently Asked Questions section.

Next

Get Started