diff --git a/source/figures/PHP_driver_architecture.svg b/source/figures/PHP_driver_architecture.svg new file mode 100644 index 000000000..67d7a0e2a --- /dev/null +++ b/source/figures/PHP_driver_architecture.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/source/php-libraries.txt b/source/php-libraries.txt index fb34b92c8..6479e452e 100644 --- a/source/php-libraries.txt +++ b/source/php-libraries.txt @@ -37,7 +37,6 @@ Standalone Libraries use this standalone library or use the `Laravel `__ integration, which adds support for failed jobs, migrations, and events. - Framework Integrations ---------------------- @@ -50,7 +49,7 @@ Framework Integrations - Laravel - - `Laravel MongoDB `__ is an + - `Laravel MongoDB `__ is an Eloquent model and Query builder that supports MongoDB by using the original Laravel API. This library extends the original Laravel classes and therefore uses the same methods. @@ -90,5 +89,4 @@ Tools and Projects a common way for programs to create, send, and read messages. - `XHGui `__ is a web interface for the - XHProf profiler, which stores profiling data in MongoDB. - + XHProf profiler, which stores profiling data in MongoDB. \ No newline at end of file diff --git a/source/php.txt b/source/php.txt index f6a8d40fb..ad2dbd1bd 100644 --- a/source/php.txt +++ b/source/php.txt @@ -4,8 +4,6 @@ MongoDB PHP Driver ================== -.. default-domain:: mongodb - .. facet:: :name: programming_language :values: php @@ -28,7 +26,6 @@ MongoDB PHP Driver :depth: 1 :class: twocols - Introduction ------------ @@ -36,19 +33,22 @@ Welcome to the documentation site for the official MongoDB PHP driver. You can add the driver to your application to work with MongoDB in PHP. The MongoDB PHP Driver consists of the two following components: -- The `extension `_, which +- The `extension `__, which provides a low-level API and mainly serves to integrate - `libmongoc and libbson `_ with + :ref:`libmongoc and libbson ` with PHP. -- The `library `_, which +- The `library `__, which provides a high-level API for working with MongoDB databases consistent with other MongoDB language drivers. While it is possible to use the extension alone, MongoDB recommends -using both the extension and the library together. Download the -components you need or set up a runnable project by following our -tutorials. +using both the extension and the library together. To learn more about +the components of the PHP driver, see the :ref:`Driver Architecture +` section of this page. + +Navigate through the following links to learn more about the driver and access +tutorial content on setting up a runnable project: - `Tutorials `__ @@ -72,6 +72,44 @@ tutorials. - `Extension `__ +.. _php-driver-arch: + +Driver Architecture +------------------- + +This section describes how the components of the PHP driver work together. +These components fit into the following general categories: + +- High-Level API, which includes the library and other integrations +- Extension, which includes the extension that integrates the system libraries +- System, which includes the C Driver, BSON library, and encryption library + +The following diagram illustrates the architecture of the PHP driver +components: + +.. figure:: /figures/PHP_driver_architecture.svg + :alt: PHP driver component architecture + :figwidth: 600px + +The PHP library provides an API that is consistent with the other +MongoDB drivers. The library is continually updated to meet cross-driver +specifications. You must add the library as a dependency to access +MongoDB in most PHP applications. + +The extension is distributed by using `PECL +`__, and +connects PHP to the system libraries. The extension's public API +provides the following functionality: + +- Connection management +- BSON encoding and decoding +- Object document serialization +- Command execution +- Cursor management + +To learn more about the system libraries, see the :ref:`C Driver +` documentation. + Compatibility ------------- @@ -80,18 +118,17 @@ following environments: .. include:: /includes/fact-environments.rst - Installation ------------ First, make sure you have a recent version of PHP installed on your system. See the -`official PHP manual `_ +`official PHP manual `__ for download and installation instructions. Install the PHP MongoDB Extension before installing the PHP Library for MongoDB. You can install the extension using -`PECL `_ on +`PECL `__ on the command line: .. code-block:: sh @@ -110,7 +147,7 @@ Finally, add the following line to your ``php.ini`` file: CLI, FPM). Make sure to enable the extension in all SAPIs that you need. The preferred method of installing the PHP library is with -`Composer `_ by running the following from your project root: +`Composer `__ by running the following from your project root: .. code-block:: sh @@ -126,7 +163,7 @@ Composer's autoloader as in the following example: require_once __DIR__ . '/vendor/autoload.php'; Additional installation instructions may be found in the -`library documentation `_. +`library documentation `__. .. _connect-atlas-php-driver: @@ -177,7 +214,7 @@ Compatibility Due to potential problems representing 64-bit integers on 32-bit platforms, users are advised to use 64-bit environments. When using a 32-bit platform, be aware that any 64-bit integer read from the database will be returned as a -`MongoDB\\BSON\\Int64 `_ +`MongoDB\\BSON\\Int64 `__ instance instead of a PHP integer type. MongoDB Compatibility