The MongoDB PHP library wraps the mongodb extension with client, database, and collection objects, CRUD, and commands aligned with other MongoDB drivers.
Overview
The MongoDB PHP library is the official high-level API for PHP applications that use MongoDB. It sits above the mongodb PHP extension, which offers a lower-level interface for connections, BSON, cursors, and command execution. The library models clients, databases, and collections and implements CRUD, index and collection management, and common commands in line with cross-driver specifications.
Installation is typically through Composer for the library and PECL for the extension. Documentation describes driver architecture among the PHP library, the extension, and underlying C driver and BSON components. The library is presented as the usual dependency for MongoDB access in PHP, not the extension alone.
Guides cover connection setup, databases and collections, CRUD, aggregation, custom data formats, indexes, database commands, MongoDB Search, MongoDB Vector Search, monitoring, logging, and securing data. AWS Lambda deployment is mentioned in overview material on the docs site.
The API is kept consistent with other MongoDB drivers and updated as cross-driver specs evolve. PHP applications are expected to depend on the library to reach MongoDB in most cases.
Key features
- Client, database, and collection models
- CRUD and common commands
- Index and collection management
- Aggregation operations
- Works with mongodb PECL extension
- Composer package installation
- MongoDB Search queries
- MongoDB Vector Search queries
Use cases
- PHP web apps on MongoDB
- High-level driver instead of extension only
- Cross-driver-consistent MongoDB API
- Search and vector queries from PHP
- Deploying PHP with MongoDB on AWS Lambda