CakeFest 2024: The Official CakePHP Conference

Architecture Overview

This article explains how all the different components of the PHP driver fit together, from base system libraries, through the extension, and to the PHP libraries on top.


     PHP Driver Architecture Diagram. The lowest level of the driver is our
     system libraries: libmongoc, libbson, and libmongocrypt. The middle level
     is the MongoDB PHP C extension. The upper level is PHP userland and
     includes the MongoDB PHP library and higher-level packages such as
     framework integrations and applications.

At the top of this stack sits a » PHP library, which is distributed as a » Composer package. This library provides an API consistent with other MongoDB » drivers and implements various cross-driver » specifications. While the extension can be used directly, the library has minimal overhead and should be a common dependency for most applications built with MongoDB.

Sitting below that library is a PHP extension, which is distributed through » PECL. The extension forms the glue between PHP and our system libraries (» libmongoc, » libbson, and » libmongocrypt). Its public API provides only the most essential functionality:

  • Connection management
  • BSON encoding and decoding
  • Object document serialization (to support ODM libraries)
  • Executing commands, queries, and write operations
  • Handling cursors for command and query results

Driver Source Code and JIRA Projects
Project GitHub JIRA
PHP Library » mongodb/mongo-php-library » PHPLIB
PHP Extension » mongodb/mongo-php-driver » PHPC

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top