Skip to content

Commit 1bed29c

Browse files
authored
Merge pull request #98 from i80and/DOP-4904-v1.16
DOP-4904: Inline docs for v1.16
2 parents a1550e3 + 2772baa commit 1bed29c

File tree

207 files changed

+20530
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+20530
-5
lines changed

.gitmodules

Lines changed: 0 additions & 4 deletions
This file was deleted.

mongo-php-library

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/.static/.mongodb

Whitespace-only changes.

source/faq.txt

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
==========================
2+
Frequently Asked Questions
3+
==========================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
Common Extension Installation Errors
14+
------------------------------------
15+
16+
PHP Headers Not Found
17+
~~~~~~~~~~~~~~~~~~~~~
18+
19+
For example:
20+
21+
.. code-block:: none
22+
23+
/private/tmp/pear/install/mongodb/php_phongo.c:24:10: fatal error: 'php.h' file not found
24+
25+
#include <php.h>
26+
^~~~~~~
27+
28+
This error indicates that PHP's build system cannot find the necessary headers.
29+
All PHP extensions require headers in order to compile. Additionally, those
30+
headers must correspond to the PHP runtime for which the extension will be used.
31+
Generally, the ``phpize`` command (invoked by ``pecl``) will ensure that the
32+
extension builds with the correct headers.
33+
34+
Note that the mere presence of a PHP runtime does not mean that headers are
35+
available. On various Linux distributions, headers are often published under a
36+
separate ``php-dev`` or ``php-devel`` package. On macOS, the default PHP runtime
37+
does not include headers and users typically need to install PHP (and headers)
38+
via `Homebrew <https://brew.sh/>`_ in order to build an extension.
39+
40+
Multiple PHP Runtimes Installed
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
43+
If your system has multiple versions of PHP installed, each version will have
44+
its own ``pecl`` and ``phpize`` commands. Additionally, each PHP runtime may
45+
have separate ``php.ini`` files for each SAPI (e.g. FPM, CLI). If the extension
46+
has been installed but is not available at runtime, double-check that you have
47+
used the correct ``pecl`` command and have modified the appropriate ``php.ini``
48+
file(s).
49+
50+
If there is any doubt about the ``php.ini`` file being used by a PHP runtime,
51+
you should examine the output of :php:`phpinfo() <phpinfo>` for that particular
52+
SAPI. Additionally, :php:`php_ini_loaded_file() <php_ini_loaded_file>` and
53+
:php:`php_ini_scanned_files() <php_ini_scanned_files>` may be used to determine
54+
exactly which INI files have been loaded by PHP.
55+
56+
To debug issues with the extension not being loaded, you can use the
57+
``detect-extension`` script provided in the tools directory. You can run this
58+
script from the CLI or include it in a script accessible via your web server.
59+
The tool will point out potential issues and installation instructions for your
60+
system. Assuming you've installed the library through Composer, you can call the
61+
script from the vendor directory:
62+
63+
.. code-block:: none
64+
65+
php vendor/mongodb/mongodb/tools/detect-extension.php
66+
67+
If you want to check configuration for a web server SAPI, include the file in
68+
a script accessible from the web server and open it in your browser. Remember to
69+
wrap the script in ``<pre>`` tags to properly format its output:
70+
71+
.. code-block:: php
72+
73+
<pre><?php require(...); ?></pre>
74+
75+
Loading an Incompatible DLL on Windows
76+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77+
78+
Windows binaries are available for various combinations of PHP version,
79+
thread safety (TS or NTS), and architecture (x86 or x64). Failure to select the
80+
correct binary will result in an error when attempting to load the extension DLL
81+
at runtime:
82+
83+
.. code-block:: none
84+
85+
PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb'
86+
87+
Ensure that you have downloaded a DLL that corresponds to the following PHP
88+
runtime properties:
89+
90+
- PHP version (``PHP_VERSION``)
91+
- Thread safety (``PHP_ZTS``)
92+
- Architecture (``PHP_INT_SIZE``)
93+
94+
In addition to the aforementioned constants, these properties can also be
95+
inferred from :php:`phpinfo() <phpinfo>`. If your system has multiple PHP
96+
runtimes installed, double-check that you are examining the ``phpinfo()`` output
97+
for the correct environment.
98+
99+
The aforementioned ``detect-extension`` script can also be used to determine the
100+
appropriate DLL for your PHP environment.
101+
102+
Server Selection Failures
103+
-------------------------
104+
105+
The following are all examples of
106+
:doc:`Server Selection </tutorial/server-selection>` failures:
107+
108+
.. code-block:: none
109+
110+
No suitable servers found (`serverSelectionTryOnce` set):
111+
[connection refused calling hello on 'a.example.com:27017']
112+
[connection refused calling hello on 'b.example.com:27017']
113+
114+
No suitable servers found: `serverSelectionTimeoutMS` expired:
115+
[socket timeout calling hello on 'example.com:27017']
116+
117+
No suitable servers found: `serverSelectionTimeoutMS` expired:
118+
[connection timeout calling hello on 'a.example.com:27017']
119+
[connection timeout calling hello on 'b.example.com:27017']
120+
[TLS handshake failed: -9806 calling hello on 'c.example.com:27017']
121+
122+
No suitable servers found: `serverselectiontimeoutms` timed out:
123+
[TLS handshake failed: certificate verify failed (64): IP address mismatch calling hello on 'a.example.com:27017']
124+
[TLS handshake failed: certificate verify failed (64): IP address mismatch calling hello on 'b.example.com:27017']
125+
126+
These errors typically manifest as a
127+
:php:`MongoDB\Driver\Exception\ConnectionTimeoutException <mongodb-driver-exception-connectiontimeoutexception>`
128+
exception from the driver. The actual exception messages originate from
129+
libmongoc, which is the underlying library used by the PHP driver. Since these
130+
messages can take many forms, it's helpful to break down the structure of the
131+
message so you can better diagnose errors in your application.
132+
133+
Messages will typically start with "No suitable servers found". The next part of
134+
the message indicates *how* server selection failed. By default, the PHP driver
135+
avoids a server selection loop and instead makes a single attempt (according to
136+
the ``serverSelectionTryOnce`` connection string option). If the driver is
137+
configured to utilize a loop, a message like "serverSelectionTimeoutMS expired"
138+
will tell us that we exhausted its time limit.
139+
140+
The last component of the message tells us *why* server selection failed, and
141+
includes one or more errors directly from the topology scanner, which is the
142+
service responsible for connecting to and monitoring each host. Any host that
143+
last experienced an error during monitoring will be included in this list. These
144+
messages typically originate from low-level socket or TLS functions.
145+
146+
The following is not meant to be exhaustive, but will hopefully point you in the
147+
right direction for analyzing the contributing factor(s) for a server selection
148+
failure:
149+
150+
- "connection refused" likely indicates that the remote host is not listening on
151+
the expected port.
152+
- "connection timeout" could indicate a routing or firewall issue, or perhaps
153+
a timeout due to latency.
154+
- "socket timeout" suggests that a connection *was* established at some point
155+
but was dropped or otherwise timed out due to latency.
156+
- "TLS handshake failed" suggests something related to TLS or OCSP verification
157+
and is sometimes indicative of misconfigured TLS certificates.
158+
159+
In the case of a connection failure, you can use the ``connect`` tool to try and
160+
receive more information. This tool attempts to connect to each host in a
161+
connection string using socket functions to see if it is able to establish a
162+
connection, send, and receive data. The tool takes the connection string to a
163+
MongoDB deployment as its only argument. Assuming you've installed the library
164+
through Composer, you would call the script from the vendor directory:
165+
166+
.. code-block:: none
167+
168+
php vendor/mongodb/mongodb/tools/connect.php mongodb://127.0.0.1:27017
169+
170+
In case the server does not accept connections, the output will look like this:
171+
172+
.. code-block:: none
173+
174+
Looking up MongoDB at mongodb://127.0.0.1:27017
175+
Found 1 host(s) in the URI. Will attempt to connect to each.
176+
177+
Could not connect to 127.0.0.1:27017: Connection refused
178+
179+
.. note::
180+
181+
The tool only supports the ``mongodb://`` URI schema. Using the
182+
``mongodb+srv`` scheme is not supported.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ref: bucket-option-readConcern
2+
source:
3+
ref: common-option-readConcern
4+
file: extracts-common-option.yaml
5+
replacement:
6+
object: bucket
7+
---
8+
ref: bucket-option-readPreference
9+
source:
10+
ref: common-option-readPreference
11+
file: extracts-common-option.yaml
12+
replacement:
13+
object: bucket
14+
---
15+
ref: bucket-option-typeMap
16+
source:
17+
ref: common-option-typeMap
18+
file: extracts-common-option.yaml
19+
replacement:
20+
object: bucket
21+
---
22+
ref: bucket-option-writeConcern
23+
source:
24+
ref: common-option-writeConcern
25+
file: extracts-common-option.yaml
26+
replacement:
27+
object: bucket
28+
...
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ref: bulkwriteexception-result
2+
content: |
3+
If a :php:`MongoDB\Driver\Exception\BulkWriteException
4+
<mongodb-driver-exception-bulkwriteexception>` is thrown, users should call
5+
:php:`getWriteResult() <mongodb-driver-writeexception.getwriteresult>` and
6+
inspect the returned :php:`MongoDB\Driver\WriteResult
7+
<mongodb-driver-writeresult>` object to determine the nature of the error.
8+
9+
For example, a write operation may have been successfully applied to the
10+
primary server but failed to satisfy the write concern (e.g. replication took
11+
too long). Alternatively, a write operation may have failed outright (e.g.
12+
unique key violation).
13+
---
14+
ref: bulkwriteexception-ordered
15+
content: |
16+
In the case of a bulk write, the result may indicate multiple successful write
17+
operations and/or errors. If the ``ordered`` option is ``true``, some
18+
operations may have succeeded before the first error was encountered and the
19+
exception thrown. If the ``ordered`` option is ``false``, multiple errors may
20+
have been encountered.
21+
...
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
ref: client-option-readConcern
2+
source:
3+
ref: common-option-readConcern
4+
file: extracts-common-option.yaml
5+
replacement:
6+
object: client
7+
---
8+
ref: client-option-readPreference
9+
source:
10+
ref: common-option-readPreference
11+
file: extracts-common-option.yaml
12+
replacement:
13+
object: client
14+
---
15+
ref: client-option-typeMap
16+
source:
17+
ref: common-option-typeMap
18+
file: extracts-common-option.yaml
19+
replacement:
20+
object: client
21+
---
22+
ref: client-option-writeConcern
23+
source:
24+
ref: common-option-writeConcern
25+
file: extracts-common-option.yaml
26+
replacement:
27+
object: client
28+
...
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
ref: collection-option-collation
2+
content: |
3+
:manual:`Collation </reference/collation>` allows users to specify
4+
language-specific rules for string comparison, such as rules for lettercase
5+
and accent marks. When specifying collation, the ``locale`` field is
6+
mandatory; all other collation fields are optional. For descriptions of the
7+
fields, see :manual:`Collation Document </reference/collation/#collation-document>`.
8+
9+
If the collation is unspecified but the collection has a default collation,
10+
the operation uses the collation specified for the collection. If no
11+
collation is specified for the collection or for the operation, MongoDB uses
12+
the simple binary comparison used in prior versions for string comparisons.
13+
---
14+
ref: collection-option-readConcern
15+
source:
16+
ref: common-option-readConcern
17+
file: extracts-common-option.yaml
18+
replacement:
19+
object: collection
20+
---
21+
ref: collection-option-readPreference
22+
source:
23+
ref: common-option-readPreference
24+
file: extracts-common-option.yaml
25+
replacement:
26+
object: collection
27+
---
28+
ref: collection-option-typeMap
29+
source:
30+
ref: common-option-typeMap
31+
file: extracts-common-option.yaml
32+
replacement:
33+
object: collection
34+
---
35+
ref: collection-option-writeConcern
36+
source:
37+
ref: common-option-writeConcern
38+
file: extracts-common-option.yaml
39+
replacement:
40+
object: collection
41+
...
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
ref: common-option-collation
2+
content: |
3+
:manual:`Collation </reference/collation>` allows users to specify
4+
language-specific rules for string comparison, such as rules for lettercase
5+
and accent marks. When specifying collation, the ``locale`` field is
6+
mandatory; all other collation fields are optional. For descriptions of the
7+
fields, see :manual:`Collation Document </reference/collation/#collation-document>`.
8+
---
9+
ref: common-option-comment
10+
content: |
11+
Enables users to specify an arbitrary comment to help trace the operation
12+
through the :manual:`database profiler </reference/database-profiler>`,
13+
:manual:`currentOp </reference/command/currentOp>` output, and
14+
:manual:`logs </reference/log-messages>`.
15+
---
16+
ref: common-option-comment-string-before-4.4
17+
content: |
18+
The comment can be any valid BSON type since MongoDB 4.4. Earlier server
19+
versions only support string values.
20+
---
21+
ref: common-option-hint
22+
content: |
23+
The index to use. Specify either the index name as a string or the index key
24+
pattern as a document. If specified, then the query system will only consider
25+
plans using the hinted index.
26+
---
27+
ref: common-option-let
28+
content: |
29+
Map of parameter names and values. Values must be constant or closed
30+
expressions that do not reference document fields. Parameters can then be
31+
accessed as variables in an aggregate expression context (e.g. ``$$var``).
32+
33+
This is not supported for server versions prior to 5.0 and will result in an
34+
exception at execution time if used.
35+
---
36+
ref: common-option-maxTimeMS
37+
content: |
38+
The cumulative time limit in milliseconds for processing operations on the
39+
cursor. MongoDB aborts the operation at the earliest following
40+
:term:`interrupt point`.
41+
---
42+
ref: common-option-readConcern
43+
content: |
44+
:manual:`Read concern </reference/read-concern>` to use for the operation.
45+
Defaults to the {{object}}'s read concern.
46+
replacement:
47+
object: object
48+
---
49+
ref: common-option-readConcern-transaction
50+
content: |
51+
It is not possible to specify a read concern for individual operations as part
52+
of a transaction. Instead, set the ``readConcern`` option when
53+
:php:`starting the transaction <mongodb-driver-session.starttransaction>`.
54+
---
55+
ref: common-option-readPreference
56+
content: |
57+
:manual:`Read preference </reference/read-preference>` to use for the
58+
operation. Defaults to the {{object}}'s read preference.
59+
replacement:
60+
object: object
61+
---
62+
ref: common-option-session
63+
content: |
64+
Client session to associate with the operation.
65+
---
66+
ref: common-option-typeMap
67+
content: |
68+
The :php:`type map <manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`
69+
to apply to cursors, which determines how BSON documents are converted to PHP
70+
values. Defaults to the {{object}}'s type map.
71+
replacement:
72+
object: object
73+
---
74+
ref: common-option-writeConcern
75+
content: |
76+
:manual:`Write concern </reference/write-concern>` to use for the operation.
77+
Defaults to the {{object}}'s write concern.
78+
replacement:
79+
object: object
80+
---
81+
ref: common-option-writeConcern-transaction
82+
content: |
83+
It is not possible to specify a write concern for individual operations as
84+
part of a transaction. Instead, set the ``writeConcern`` option when
85+
:php:`starting the transaction <mongodb-driver-session.starttransaction>`.
86+
...

0 commit comments

Comments
 (0)