Skip to content

Commit 3f5a86a

Browse files
authored
PHPLIB-572: Add debugging tools (#996)
* Add connection debugging script * Fix grammar * Add extension detection script * Fix wording feedback * Document using pre tags for formatted output in web SAPI
1 parent b8d6fec commit 3f5a86a

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

source/faq.txt

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,25 @@ SAPI. Additionally, :php:`php_ini_loaded_file() <php_ini_loaded_file>` and
5353
:php:`php_ini_scanned_files() <php_ini_scanned_files>` may be used to determine
5454
exactly which INI files have been loaded by PHP.
5555

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+
5675
Loading an Incompatible DLL on Windows
5776
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5877

@@ -80,7 +99,7 @@ for the correct environment.
8099
Server Selection Failures
81100
-------------------------
82101

83-
The follow are all examples of
102+
The following are all examples of
84103
:doc:`Server Selection </tutorial/server-selection>` failures:
85104

86105
.. code-block:: none
@@ -133,3 +152,28 @@ failure:
133152
but was dropped or otherwise timeout out due to latency.
134153
- "TLS handshake failed" suggests something related to TLS or OCSP verification
135154
and is sometimes indicative of misconfigured TLS certificates.
155+
156+
In the case of a connection failure, you can use the ``connect`` tool to try and
157+
receive more information. This tool attempts to connect to each host in a
158+
connection string using socket functions to see if it is able to establish a
159+
connection, send, and receive data. The tool takes the connection string to a
160+
MongoDB deployment as its only argument. Assuming you've installed the library
161+
through Composer, you would call the script from the vendor directory:
162+
163+
.. code-block:: none
164+
165+
php vendor/mongodb/mongodb/tools/connect.php mongodb://127.0.0.1:27017
166+
167+
In case the server does not accept connections, the output will look like this:
168+
169+
.. code-block:: none
170+
171+
Looking up MongoDB at mongodb://127.0.0.1:27017
172+
Found 1 host(s) in the URI. Will attempt to connect to each.
173+
174+
Could not connect to 127.0.0.1:27017: Connection refused
175+
176+
.. note::
177+
178+
The tool only supports the ``mongodb://`` URI schema. Using the
179+
``mongodb+srv`` scheme is not supported.

0 commit comments

Comments
 (0)