4
4
MongoDB PHP Driver
5
5
==================
6
6
7
- .. default-domain:: mongodb
8
-
9
7
.. facet::
10
8
:name: programming_language
11
9
:values: php
@@ -28,27 +26,29 @@ MongoDB PHP Driver
28
26
:depth: 1
29
27
:class: twocols
30
28
31
-
32
29
Introduction
33
30
------------
34
31
35
32
Welcome to the documentation site for the official MongoDB PHP driver.
36
33
You can add the driver to your application to work with MongoDB in PHP.
37
34
The MongoDB PHP Driver consists of the two following components:
38
35
39
- - The `extension <https://github.com/mongodb/mongo-php-driver>`_ , which
36
+ - The `extension <https://github.com/mongodb/mongo-php-driver>`__ , which
40
37
provides a low-level API and mainly serves to integrate
41
- `libmongoc and libbson <https://www.mongodb.com/docs/drivers/c/>`_ with
38
+ :ref: `libmongoc and libbson <c-language-center>` with
42
39
PHP.
43
40
44
- - The `library <https://www.mongodb.com/docs/php-library/current>`_ , which
41
+ - The `library <https://www.mongodb.com/docs/php-library/current>`__ , which
45
42
provides a high-level API for working with MongoDB
46
43
databases consistent with other MongoDB language drivers.
47
44
48
45
While it is possible to use the extension alone, MongoDB recommends
49
- using both the extension and the library together. Download the
50
- components you need or set up a runnable project by following our
51
- tutorials.
46
+ using both the extension and the library together. To learn more about
47
+ the components of the PHP driver, see the :ref:`Driver Architecture
48
+ <php-driver-arch>` section of this page.
49
+
50
+ Navigate through the following links to learn more about the driver and access
51
+ tutorial content on setting up a runnable project:
52
52
53
53
- `Tutorials <https://www.mongodb.com/docs/php-library/current/tutorial>`__
54
54
@@ -72,6 +72,44 @@ tutorials.
72
72
73
73
- `Extension <https://github.com/mongodb/mongo-php-driver>`__
74
74
75
+ .. _php-driver-arch:
76
+
77
+ Driver Architecture
78
+ -------------------
79
+
80
+ This section describes how the components of the PHP driver work together.
81
+ These components fit into the following general categories:
82
+
83
+ - High-Level API, which includes the library and other integrations
84
+ - Extension, which includes the extension that integrates the system libraries
85
+ - System, which includes the C Driver, BSON library, and encryption library
86
+
87
+ The following diagram illustrates the architecture of the PHP driver
88
+ components:
89
+
90
+ .. figure:: /figures/PHP_driver_architecture.svg
91
+ :alt: PHP driver component architecture
92
+ :figwidth: 600px
93
+
94
+ The PHP library provides an API that is consistent with the other
95
+ MongoDB drivers. The library is continually updated to meet cross-driver
96
+ specifications. You must add the library as a dependency to access
97
+ MongoDB in most PHP applications.
98
+
99
+ The extension is distributed by using `PECL
100
+ <https://www.php.net/manual/en/mongodb.installation.pecl.php>`__, and
101
+ connects PHP to the system libraries. The extension's public API
102
+ provides the following functionality:
103
+
104
+ - Connection management
105
+ - BSON encoding and decoding
106
+ - Object document serialization
107
+ - Command execution
108
+ - Cursor management
109
+
110
+ To learn more about the system libraries, see the :ref:`C Driver
111
+ <c-language-center>` documentation.
112
+
75
113
Compatibility
76
114
-------------
77
115
@@ -80,18 +118,17 @@ following environments:
80
118
81
119
.. include:: /includes/fact-environments.rst
82
120
83
-
84
121
Installation
85
122
------------
86
123
87
124
First, make sure you have a recent version of PHP installed on your
88
125
system. See the
89
- `official PHP manual <https://www.php.net/manual/en/install.php>`_
126
+ `official PHP manual <https://www.php.net/manual/en/install.php>`__
90
127
for download and installation instructions.
91
128
92
129
Install the PHP MongoDB Extension before installing the PHP Library for
93
130
MongoDB. You can install the extension using
94
- `PECL <https://www.php.net/manual/en/mongodb.installation.pecl.php>`_ on
131
+ `PECL <https://www.php.net/manual/en/mongodb.installation.pecl.php>`__ on
95
132
the command line:
96
133
97
134
.. code-block:: sh
@@ -110,7 +147,7 @@ Finally, add the following line to your ``php.ini`` file:
110
147
CLI, FPM). Make sure to enable the extension in all SAPIs that you need.
111
148
112
149
The preferred method of installing the PHP library is with
113
- `Composer <https://getcomposer.org/>`_ by running the following from your project root:
150
+ `Composer <https://getcomposer.org/>`__ by running the following from your project root:
114
151
115
152
.. code-block:: sh
116
153
@@ -126,7 +163,7 @@ Composer's autoloader as in the following example:
126
163
require_once __DIR__ . '/vendor/autoload.php';
127
164
128
165
Additional installation instructions may be found in the
129
- `library documentation <https://www.mongodb.com/docs/php-library/current/tutorial/install-php-library/>`_ .
166
+ `library documentation <https://www.mongodb.com/docs/php-library/current/tutorial/install-php-library/>`__ .
130
167
131
168
.. _connect-atlas-php-driver:
132
169
@@ -177,7 +214,7 @@ Compatibility
177
214
Due to potential problems representing 64-bit integers on 32-bit platforms,
178
215
users are advised to use 64-bit environments. When using a 32-bit platform, be
179
216
aware that any 64-bit integer read from the database will be returned as a
180
- `MongoDB\\BSON\\Int64 <https://www.php.net/manual/en/class.mongodb-bson-int64.php>`_
217
+ `MongoDB\\BSON\\Int64 <https://www.php.net/manual/en/class.mongodb-bson-int64.php>`__
181
218
instance instead of a PHP integer type.
182
219
183
220
MongoDB Compatibility
0 commit comments