Skip to content

Commit 1104051

Browse files
authored
DOCSP-41952: Download and Install (#92)
* DOCSP-41952: Download and Install * edits * toc, fixes * AS feedback * AS feedback 2 * typo * JT feedback
1 parent e994533 commit 1104051

File tree

5 files changed

+126
-103
lines changed

5 files changed

+126
-103
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ toc_landing_pages = [
1717
"/reference/class/MongoDBModelCollectionInfo",
1818
"/reference/class/MongoDBModelDatabaseInfo",
1919
"/reference/class/MongoDBModelIndexInfo",
20+
"/get-started",
2021
]
2122

2223
[substitutions]

source/get-started.txt

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,33 @@ Get Started with the PHP Library
1313
.. facet::
1414
:name: genre
1515
:values: tutorial
16-
16+
1717
.. meta::
1818
:description: Learn how to create an app to connect to MongoDB deployment by using the PHP library.
1919
:keywords: quick start, tutorial, basics
2020

2121
.. toctree::
2222

23+
/get-started/download-and-install/
2324
/get-started/create-a-deployment/
2425
/get-started/create-a-connection-string/
25-
/get-started/next-steps/
26+
/get-started/next-steps/
27+
28+
Overview
29+
--------
30+
31+
The {+php-library+} is a high-level abstraction for the MongoDB PHP extension, which
32+
you can use to connect to MongoDB and interact with data stored in your deployment.
33+
This guide shows you how to create an application that uses the {+php-library+} to
34+
connect to a MongoDB cluster hosted on MongoDB Atlas and query data in your cluster.
35+
36+
.. tip::
37+
38+
MongoDB Atlas is a fully managed cloud database service that hosts your MongoDB
39+
deployments. You can create your own free (no credit card required) MongoDB Atlas
40+
deployment by following the steps in this guide.
41+
42+
Follow this guide to connect a sample PHP application to a MongoDB Atlas
43+
deployment. If you prefer to connect to MongoDB using a different driver or
44+
programming language, see our :driver:`list of official drivers <>`.
45+
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
.. _php-download-and-install:
2+
3+
====================
4+
Download and Install
5+
====================
6+
7+
.. facet::
8+
:name: genre
9+
:values: tutorial
10+
11+
.. meta::
12+
:keywords: setup, composer, installation, code example
13+
14+
.. procedure::
15+
:style: connected
16+
17+
.. step:: Install dependencies
18+
19+
Before you begin developing, ensure that you have the following
20+
dependencies installed on your local machine:
21+
22+
- `PHP <https://www.php.net/manual/en/install.php>`__ version 7.4 or later
23+
- `Composer <https://getcomposer.org/download/>`__ version 2.0 or later
24+
25+
.. step:: Install the MongoDB PHP extension
26+
27+
Run the following command to install the ``mongodb`` PHP extension:
28+
29+
.. code-block:: bash
30+
31+
sudo pecl install mongodb
32+
33+
.. step:: Update your PHP configuration file
34+
35+
To enable the ``mongodb`` extension in your PHP configuration file, add the
36+
following line to the top of your ``php.ini`` file:
37+
38+
.. code-block:: none
39+
40+
extension=mongodb.so
41+
42+
.. tip::
43+
44+
You can locate your ``php.ini`` file by running the following command
45+
in your shell:
46+
47+
.. code-block:: bash
48+
49+
php --ini
50+
51+
.. step:: Create a project directory
52+
53+
From your root directory, run the following command in your shell to create
54+
a directory called ``php-quickstart`` for this project:
55+
56+
.. code-block:: bash
57+
58+
mkdir php-quickstart
59+
60+
Select the tab corresponding to your operating system and run the following commands
61+
to create a ``quickstart.php`` application file in the ``php-quickstart`` directory:
62+
63+
.. tabs::
64+
65+
.. tab:: macOS / Linux
66+
:tabid: create-file-mac-linux
67+
68+
.. code-block:: bash
69+
70+
cd php-quickstart
71+
touch quickstart.php
72+
73+
.. tab:: Windows
74+
:tabid: create-file-windows
75+
76+
.. code-block:: bash
77+
78+
cd php-quickstart
79+
type nul > quickstart.php
80+
81+
.. step:: Install the {+php-library+}
82+
83+
To install the {+php-library+}, run the following command in your ``php-quickstart``
84+
directory:
85+
86+
.. code-block:: bash
87+
88+
composer require mongodb/mongodb
89+
90+
After installing the library, include Composer's ``autoload.php`` file by adding the
91+
following code to the top of your ``quickstart.php`` file:
92+
93+
.. code-block:: php
94+
95+
<?php
96+
97+
require_once __DIR__ . '/vendor/autoload.php';
98+
99+
After you complete these steps, you have a new project directory, a
100+
new application file, and the library dependencies installed.
101+
102+
.. include:: /includes/get-started/troubleshoot.rst

source/index.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ MongoDB PHP Library
1010
.. toctree::
1111
:titlesonly:
1212

13-
Installation </tutorial/install-php-library>
1413
Get Started </get-started>
1514
/read
1615
/tutorial
@@ -39,7 +38,7 @@ New to the PHP Library?
3938
If you have some experience with MongoDB but are new to the PHP library, the
4039
following pages should help you get started:
4140

42-
- :doc:`/tutorial/install-php-library`
41+
- :ref:`php-download-and-install`
4342

4443
- :doc:`/tutorial/connecting`
4544

source/tutorial/install-php-library.txt

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

0 commit comments

Comments
 (0)