Skip to content

Commit a5be07f

Browse files
committed
Merge branch 'v1.4' into v1.5
2 parents 004cfa7 + 10ecea3 commit a5be07f

File tree

6 files changed

+113
-59
lines changed

6 files changed

+113
-59
lines changed

docs/index.txt

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,53 @@ The |php-library| provides a high-level abstraction around the lower-level
88
`PHP driver <https://php.net/mongodb>`_, also known as the ``mongodb``
99
extension.
1010

11-
While the ``mongodb`` extension provides a limited API for executing commands,
12-
queries, and write operations, the |php-library| implements an API similar to
13-
that of the `legacy PHP driver <http://php.net/manual/en/book.mongo.php>`_. The
14-
library contains abstractions for client, database, and collection objects, and
15-
provides methods for CRUD operations and common commands such as index and
16-
collection management.
11+
The ``mongodb`` extension provides a limited API to connect to the database and
12+
execute generic commands, queries, and write operations. In contrast, the
13+
|php-library| provides a full-featured API and models client, database, and
14+
collection objects. Each of those classes provide various helper methods for
15+
performing operations in context. For example, :phpclass:`MongoDB\\Collection`
16+
implements methods for executing CRUD operations and managing indexes on the
17+
collection, among other things.
1718

1819
If you are developing a PHP application with MongoDB, you should consider using
19-
this library, or another high-level abstraction, instead of the extension alone.
20+
the |php-library| instead of the extension alone.
2021

21-
For additional information about this library and the ``mongodb`` extension, see
22-
the `Architecture Overview <http://php.net/manual/en/mongodb.overview.php>`_
23-
article in the extension documentation. `Derick Rethans
24-
<http://derickrethans.nl/>`_ has also written a series of blog posts entitled
25-
*New MongoDB Drivers for PHP and HHVM*:
22+
New to the PHP Library?
23+
-----------------------
2624

27-
- `Part One: History <https://derickrethans.nl/new-drivers.html>`_
25+
If you have some experience with MongoDB but are new to the PHP library, the
26+
following pages should help you get started:
2827

29-
- `Part Two: Architecture
30-
<https://derickrethans.nl/new-drivers-part2.html>`_
28+
- :doc:`/tutorial/install-php-library`
3129

32-
- `Part Three: Cursor Behaviour
33-
<https://derickrethans.nl/new-drivers-part3-cursor.html>`_
30+
- :doc:`/tutorial/crud`
31+
32+
- :doc:`/tutorial/commands`
33+
34+
- :doc:`/tutorial/gridfs`
35+
36+
- :doc:`/reference/bson`
37+
38+
If you have previously worked with the
39+
`legacy PHP driver <http://php.net/manual/en/book.mongo.php>`_ (i.e. ``mongo``
40+
extension), it will be helpful to review the :doc:`/upgrade` for a summary of
41+
API changes between the old driver and this library.
3442

3543
New to MongoDB?
3644
---------------
3745

38-
If you are a new MongoDB user, these links should help you become more familiar
39-
with MongoDB and introduce some of the concepts and terms you will encounter in
40-
this documentation:
46+
If you are a new MongoDB user, the following links should help you become more
47+
familiar with MongoDB and introduce some of the concepts and terms you will
48+
encounter in the library documentation:
4149

42-
- :manual:`Introduction to CRUD operations in MongoDB </core/crud>`
50+
- :manual:`Introduction to MongoDB </introduction>`
4351

44-
- :manual:`What is a MongoDB document? </core/document>`
52+
- :manual:`Databases and Collections </core/databases-and-collections>`
4553

46-
- :manual:`Dot notation for accessing document properties
47-
</core/document/#dot-notation>`
54+
- :manual:`Documents </core/document>` and
55+
:manual:`BSON Types </reference/bson-types>`
4856

49-
- :manual:`ObjectId: MongoDB's document identifier </reference/object-id/>`
57+
- :manual:`MongoDB CRUD Operations </crud>`
5058

5159
.. class:: hidden
5260

@@ -57,5 +65,3 @@ this documentation:
5765
/tutorial
5866
/upgrade
5967
/reference
60-
61-
.. /getting-started

docs/reference/method/MongoDBCollection-createIndex.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ exists.
8282

8383
<?php
8484

85-
$collection = (new MongoDB\Client)->selectCollection('test, 'restaurants');
85+
$collection = (new MongoDB\Client)->selectCollection('test', 'restaurants');
8686

8787
$indexName = $collection->createIndex(
8888
['borough' => 1],

docs/reference/method/MongoDBCollection-deleteMany.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,5 @@ See Also
7878
- :phpmethod:`MongoDB\\Collection::deleteOne()`
7979
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
8080
- :doc:`/tutorial/crud`
81-
- :manual:`delete </reference/command/delete` command reference in the MongoDB
81+
- :manual:`delete </reference/command/delete>` command reference in the MongoDB
8282
manual

docs/reference/method/MongoDBCollection-deleteOne.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,5 @@ See Also
8080
- :phpmethod:`MongoDB\\Collection::deleteMany()`
8181
- :phpmethod:`MongoDB\\Collection::bulkWrite()`
8282
- :doc:`/tutorial/crud`
83-
- :manual:`delete </reference/command/delete` command reference in the MongoDB
83+
- :manual:`delete </reference/command/delete>` command reference in the MongoDB
8484
manual

docs/tutorial/example-data.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The output would then resemble::
3939
You may also import the datasets using :manual:`mongoimport
4040
</reference/program/mongoimport>`, which is included with MongoDB:
4141

42-
.. code-block:: none
42+
.. code-block:: sh
4343

44-
$ mongoimport --db test --collection zips --file zips.json --drop
45-
$ mongoimport --db test --collection restaurants --file primer-dataset.json --drop
44+
mongoimport --db test --collection zips --file zips.json --drop
45+
mongoimport --db test --collection restaurants --file primer-dataset.json --drop

docs/tutorial/install-php-library.txt

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,55 +4,103 @@ Install the |php-library|
44

55
.. default-domain:: mongodb
66

7-
Prerequisites
8-
-------------
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
The |php-library| is a high-level abstraction for the
14+
`PHP driver <https://php.net/mongodb>`_ (i.e. ``mongodb`` extension). This page
15+
will briefly explain how to install both the ``mongodb`` extension and the
16+
|php-library|.
17+
18+
Installing the Extension
19+
------------------------
20+
21+
Linux, Unix, and macOS users can either
22+
:php:`install the extension with PECL <manual/en/mongodb.installation.pecl.php>`
23+
(recommended) or
24+
:php:`manually compile from source <manual/en/mongodb.installation.manual.php>`.
25+
The following command may be used to install the extension with PECL:
926

10-
The |php-library| is a high-level abstraction for the MongoDB PHP driver. As
11-
such, you must install the `mongodb` extension to use the library.
27+
.. code-block:: sh
28+
29+
sudo pecl install mongodb
30+
31+
.. note::
32+
33+
If the build process for either installation method fails to find a TLS
34+
library, check that the development packages (e.g. ``libssl-dev``) and
35+
`pkg-config <https://en.wikipedia.org/wiki/Pkg-config>`_ are both installed.
36+
37+
Once the extension is installed, add the following line to your ``php.ini``
38+
file:
39+
40+
.. code-block:: ini
1241

13-
:php:`Installing the MongoDB PHP Driver <manual/en/mongodb.installation.php>`
14-
describes how to install the `mongodb` extension for PHP. Instructions for
15-
installing the driver for HHVM may be found in the :php:`Installation with HHVM
16-
<manual/en/mongodb.installation.hhvm>` article.
42+
extension=mongodb.so
1743

18-
Procedure
19-
---------
44+
Windows users can download precompiled binaries of the extension from
45+
`PECL <https://pecl.php.net/package/mongodb>`_. After extracting the
46+
``php_mongodb.dll`` file to PHP's extension directory, add the following line to
47+
your ``php.ini`` file:
2048

21-
Install the Library
22-
~~~~~~~~~~~~~~~~~~~
49+
.. code-block:: ini
2350

24-
The preferred method of installing |php-library| is with `Composer
25-
<https://getcomposer.org/>`_ by running the following from your project
26-
root:
51+
extension=php_mongodb.dll
52+
53+
Windows binaries are available for various combinations of PHP version,
54+
thread-safety, and architecture. Failure to select the correct binary will
55+
result in an error attempting to load the extension DLL at runtime. Additional
56+
considerations for Windows are discussed in the
57+
:php:`Windows installation documentation <manual/en/mongodb.installation.windows.php>`.
58+
59+
.. note::
60+
61+
If your system has multiple versions of PHP installed, each version will have
62+
its own ``pecl`` command and ``php.ini`` file. Additionally, PHP may also use
63+
separate ``php.ini`` files for its web and CLI environments. If the extension
64+
has been installed but is not available at runtime, double-check that you
65+
have used the correct ``pecl`` command (or binary in the case of Windows) and
66+
have modified the appropriate ``php.ini`` file(s).
67+
68+
Installing the Library
69+
----------------------
70+
71+
The preferred method of installing the |php-library| is with
72+
`Composer <https://getcomposer.org/>`_ by running the following command from
73+
your project root:
2774

2875
.. code-block:: sh
2976

3077
composer require mongodb/mongodb
3178

32-
While not recommended, you may also manually install the package via
33-
the source tarballs attached to the `GitHub releases
34-
<https://github.com/mongodb/mongo-php-library/releases>`_.
79+
While not recommended, you may also manually install the library using a source
80+
archive attached to the
81+
`GitHub releases <https://github.com/mongodb/mongo-php-library/releases>`_.
3582

3683
Configure Autoloading
3784
~~~~~~~~~~~~~~~~~~~~~
3885

39-
Once you have installed the library, ensure that your application
40-
includes Composer's autoloader. The ``require_once``
41-
statement should point to Composer's autoloader, as in the following example:
86+
Once you have installed the library, ensure that your application includes
87+
Composer's autoloader as in the following example:
4288

4389
.. code-block:: php
4490

45-
require_once __DIR__ . "/vendor/autoload.php";
91+
<?php
92+
93+
require_once __DIR__ . '/vendor/autoload.php';
4694

4795
Refer to Composer's `autoloading documentation
4896
<https://getcomposer.org/doc/01-basic-usage.md#autoloading>`_ for more
4997
information about setting up autoloading.
5098

51-
If you installed the library manually from a source tarball, you
52-
will also need to manually configure autoloading:
99+
If you installed the library manually from a source archive, you will need to
100+
manually configure autoloading:
53101

54102
#. Map the top-level ``MongoDB\`` namespace to the ``src/`` directory
55103
using your preferred autoloader implementation.
56104

57-
#. Manually require the ``src/functions.php`` file, since PHP does not
58-
yet support function autoloading.
105+
#. Manually require the ``src/functions.php`` file. This is necessary because
106+
PHP does not support autoloading for functions.

0 commit comments

Comments
 (0)