|
| 1 | +.. _php-connection-string: |
| 2 | + |
| 3 | +========================== |
| 4 | +Create a Connection String |
| 5 | +========================== |
| 6 | + |
| 7 | +.. facet:: |
| 8 | + :name: genre |
| 9 | + :values: tutorial |
| 10 | + |
| 11 | +.. meta:: |
| 12 | + :keywords: uri, atlas |
| 13 | + |
| 14 | +You can connect to your MongoDB deployment by providing a |
| 15 | +**connection URI**, also called a *connection string*, which |
| 16 | +instructs the driver on how to connect to a MongoDB deployment |
| 17 | +and how to behave while connected. |
| 18 | + |
| 19 | +The connection string includes the hostname or IP address and |
| 20 | +port of your deployment, the authentication mechanism, user credentials |
| 21 | +when applicable, and connection options. |
| 22 | + |
| 23 | +.. TODO: |
| 24 | + To connect to an instance or deployment not hosted on Atlas, see |
| 25 | + :ref:`php-connection-targets`. |
| 26 | + |
| 27 | +.. procedure:: |
| 28 | + :style: connected |
| 29 | + |
| 30 | + .. step:: Find your MongoDB Atlas Connection String |
| 31 | + |
| 32 | + To retrieve your connection string for the deployment that |
| 33 | + you created in the :ref:`previous step <php-create-deployment>`, |
| 34 | + log in to your Atlas account and navigate to the |
| 35 | + :guilabel:`Database` section and click the :guilabel:`Connect` button |
| 36 | + for your new deployment. |
| 37 | + |
| 38 | + .. figure:: /includes/figures/atlas_connection_select_cluster.png |
| 39 | + :alt: The connect button in the clusters section of the Atlas UI |
| 40 | + |
| 41 | + Then, select your user from the :guilabel:`Select database user` |
| 42 | + selection menu. Select "PHP" from the :guilabel:`Driver` selection |
| 43 | + menu and the version that best matches the version you installed |
| 44 | + from the :guilabel:`Version` selection menu. |
| 45 | + |
| 46 | + Select the :guilabel:`String` tab in the :guilabel:`Add connection string into your application code` |
| 47 | + step to view only the connection string. |
| 48 | + |
| 49 | + .. step:: Copy your Connection String |
| 50 | + |
| 51 | + Click the button on the right of the connection string to copy it |
| 52 | + to your clipboard, as shown in the following screenshot: |
| 53 | + |
| 54 | + .. figure:: /includes/figures/atlas_connection_copy_string_php.png |
| 55 | + :alt: The copy button next to the connection string in the Atlas UI |
| 56 | + |
| 57 | + .. step:: Update the Placeholders |
| 58 | + |
| 59 | + Paste this connection string into a file in your preferred text editor |
| 60 | + and replace the ``<username>`` and ``<password>`` placeholders with |
| 61 | + your database user's username and password. |
| 62 | + |
| 63 | + Save this file to a safe location for use in the next step. |
| 64 | + |
| 65 | +After completing these steps, you have a connection string that |
| 66 | +corresponds to your Atlas cluster. |
| 67 | + |
| 68 | +.. include:: /includes/get-started/troubleshoot.rst |
0 commit comments