1
1
.. _php-language-center:
2
2
3
+ .. include:: /includes/unicode-checkmark.rst
4
+
3
5
==================
4
6
MongoDB PHP Driver
5
7
==================
@@ -12,33 +14,67 @@ MongoDB PHP Driver
12
14
:depth: 1
13
15
:class: twocols
14
16
15
- For the official MongoDB PHP Driver reference, see:
17
+ Introduction
18
+ ------------
16
19
17
- - `MongoDB PHP Library Documentation
18
- <https://docs.mongodb.com/php-library/ >`_
20
+ The currently maintained driver is the `mongodb
21
+ <https://pecl.php.net/package/mongodb >`_ extension available from PECL.
19
22
20
- - `MongoDB PHP Extension Documentation
21
- <http://php.net/manual/en/set.mongodb.php>`_
23
+ You might consider using the driver with the complimentary `PHP library
24
+ <https://github.com/mongodb/mongo-php-library>`_, which implements a more
25
+ full-featured API on top of the bare-bones driver.
22
26
23
- Drivers
24
- -------
27
+ Further information on this architecture may be found
28
+ in the `PHP.net documentation <http://php.net/manual/en/mongodb.overview.php>`_.
29
+
30
+ - `Tutorials <https://www.php.net/manual/en/mongodb.tutorial.php>`__
31
+
32
+ - `Driver Architecture and Internals <https://www.php.net/manual/en/mongodb.architecture.php>`__
33
+
34
+ - `API Reference <https://php.net/manual/en/book.mongodb.php>`_
35
+
36
+ - `Changelog <https://github.com/mongodb/mongo-php-driver/releases>`__
37
+
38
+ - `Source Code <https://github.com/mongodb/mongo-php-driver>`__
39
+
40
+
41
+ Installation
42
+ ------------
43
+
44
+ You can install the driver using
45
+ `PECL <https://www.php.net/manual/en/mongodb.installation.pecl.php>`_:
46
+
47
+ .. code-block:: sh
48
+
49
+ $ pecl install mongodb
50
+ $ echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
51
+
52
+ The preferred method of installing the optional but recommended PHP library is with
53
+ `Composer <https://getcomposer.org/>`_ by running the following from your project root:
54
+
55
+ .. code-block:: sh
56
+
57
+ $ composer require mongodb/mongodb
58
+
59
+ Additional installation instructions may be found in the
60
+ `library documentation <https://docs.mongodb.com/php-library/current/tutorial/install-php-library/>`_.
61
+
62
+
63
+ Connect to MongoDB Atlas
64
+ ------------------------
65
+
66
+ To connect to a `MongoDB Atlas <https://docs.atlas.mongodb.com/>`_ cluster, use the `Atlas connection string <https://docs.atlas.mongodb.com/driver-connection>`__ for your cluster:
67
+
68
+ .. code-block:: php
69
+
70
+ <?php
71
+
72
+ $client = new MongoDB\Client(
73
+ 'mongodb+srv://<username>:<password>@<cluster-address>/test?retryWrites=true&w=majority'
74
+ );
75
+
76
+ $db = $client->test;
25
77
26
- The currently maintained driver is the `mongodb
27
- <https://pecl.php.net/package/mongodb>`_ extension available from PECL. This
28
- driver can be used stand-alone, although it is very bare-bones. You should
29
- consider using the driver with the complimentary `PHP library
30
- <https://github.com/mongodb/mongo-php-library>`_, which implements a more
31
- full-featured API on top of the bare-bones driver. Further information on this
32
- architecture may be found in the `PHP.net documentation
33
- <http://php.net/manual/en/mongodb.overview.php>`_.
34
-
35
- The `mongo <https://pecl.php.net/package/mongo>`_ extension available from PECL
36
- is an older, legacy driver for PHP 5.x. The ``mongo`` extension is no longer
37
- maintained and new projects are advised to use the ``mongodb`` extension and
38
- PHP library. A community-developed `Mongo PHP Adapter
39
- <https://github.com/alcaeus/mongo-php-adapter>`_ project implements the legacy
40
- ``mongo`` extension's API using the new ``mongodb`` extension and PHP library,
41
- which may be useful for those wishing to migrate existing applications.
42
78
43
79
Compatibility
44
80
-------------
@@ -55,48 +91,16 @@ MongoDB Compatibility
55
91
Language Compatibility
56
92
~~~~~~~~~~~~~~~~~~~~~~
57
93
58
- .. include:: /includes/extracts/php-driver-compatibility-matrix-language.rst
59
-
60
- .. list-table::
61
- :header-rows: 1
62
- :stub-columns: 1
63
- :class: compatibility-large
64
-
65
- * - PHP Driver
66
- - PHP 5.5
67
- - PHP 5.6
68
- - PHP 7.0
69
- - PHP 7.1
70
- - PHP 7.2
71
- - PHP 7.3
72
-
73
- * - mongodb-1.5
74
- - |checkmark|
75
- - |checkmark|
76
- - |checkmark|
77
- - |checkmark|
78
- - |checkmark|
79
- - |checkmark|
80
-
81
- * - mongodb-1.4
82
- - |checkmark|
83
- - |checkmark|
84
- - |checkmark|
85
- - |checkmark|
86
- - |checkmark|
87
- -
88
-
89
- * - mongodb-1.3
90
- - |checkmark|
91
- - |checkmark|
92
- - |checkmark|
93
- - |checkmark|
94
- - |checkmark|
95
- -
96
-
97
- .. include:: /includes/extracts/php-driver-compatibility-full-language.rst
94
+ .. include:: /includes/language-compatibility-table-php.rst
95
+
96
+ How to get help
97
+ ---------------
98
+
99
+ - Join our `Google Group <https://groups.google.com/forum/#!forum/mongodb-user>`__.
100
+ - Ask on `Stack Overflow <https://stackoverflow.com/questions/tagged/mongodb+php>`__.
101
+ - Visit our `Support Channels <https://docs.mongodb.com/manual/support/>`__.
102
+ - See our `JIRA <https://jira.mongodb.org/projects/PHP/summary>`__ to raise issues or request features.
98
103
99
- .. include:: /includes/unicode-checkmark.rst
100
104
101
105
See Also
102
106
--------
@@ -109,3 +113,6 @@ See Also
109
113
:titlesonly:
110
114
111
115
/drivers/php-libraries
116
+
117
+
118
+
0 commit comments