File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
require __DIR__ . '/../vendor/autoload.php ' ;
4
4
5
- use MongoDB \Client ;
5
+ $ uri = getenv ('MONGODB_URI ' ) ?: throw new RuntimeException ('Set the MONGODB_URI variable to your Atlas URI that connects to the sample dataset ' );
6
+ $ client = new MongoDB \Client ($ uri );
6
7
7
- $ client = new Client ('<connection string> ' );
8
- $ collection = $ client -><database >-><collection>;
8
+ $ collection = $ client ->selectCollection ('<database> ' , '<collection> ' );
9
9
10
10
// Start example code here
11
11
Original file line number Diff line number Diff line change @@ -38,9 +38,10 @@ different types of indexes by using the {+php-library+}.
38
38
39
39
To use an example from this page, copy the code example into the
40
40
:ref:`sample application <php-index-sample>` or your own application.
41
- Be sure to replace all placeholders in the code examples, such as
42
- ``<connection string>``, with the relevant values for your MongoDB
43
- deployment.
41
+ Make sure to set the ``MONGODB_URI`` environment variable to the
42
+ connection string for your MongoDB deployment, and replace the
43
+ ``<database>`` and ``<collection>`` placeholders with values for your
44
+ target namespace.
44
45
45
46
.. _php-index-sample:
46
47
You can’t perform that action at this time.
0 commit comments