Skip to content

Commit 6418d93

Browse files
committed
DOCSP-41952: Download and Install
1 parent 37aeae4 commit 6418d93

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

source/get-started.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
.. _php-get-started:
2+
3+
================================
4+
Get Started with the PHP Library
5+
================================
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 2
11+
:class: singlecol
12+
13+
.. facet::
14+
:name: genre
15+
:values: tutorial
16+
17+
.. meta::
18+
:description: Learn how to create an app to connect to MongoDB deployment by using the PHP library.
19+
:keywords: quick start, tutorial, basics
20+
21+
.. toctree::
22+
23+
/get-started/download-and-install/
24+
25+
Overview
26+
--------
27+
28+
The {+php-library+} is a high-level abstraction for the MongoDB PHP extension, which
29+
you can use to connect to MongoDB and interact with data stored in your deployment.
30+
This guide shows you how to create an application that uses the {+php-library+} to
31+
connect to a MongoDB cluster hosted on MongoDB Atlas and query data in your cluster.
32+
33+
.. tip::
34+
35+
MongoDB Atlas is a fully managed cloud database service that hosts your MongoDB
36+
deployments. You can create your own free (no credit card required) MongoDB Atlas
37+
deployment by following the steps in this guide.
38+
39+
Follow this guide to connect a sample PHP application to a MongoDB Atlas
40+
deployment. If you prefer to connect to MongoDB using a different driver or
41+
programming language, see our :driver:`list of official drivers <>`.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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>`__
23+
- `Composer <https://getcomposer.org/download/>`__
24+
25+
.. step:: Install the MongoDB 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, add the following line to your
36+
``php.ini`` file:
37+
38+
.. code-block:: bash
39+
40+
extension=mongodb.so
41+
42+
.. tip::
43+
44+
You can locate your ``php.ini`` file by running the following command
45+
from 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+
Run the following commands to create a ``quickstart.php`` application file in
61+
the ``php-quickstart`` directory:
62+
63+
.. code-block:: bash
64+
65+
cd php-quickstart
66+
touch quickstart.php
67+
68+
.. step:: Install the {+php-library+}
69+
70+
To install the {+php-library+}, run the following command from your ``php-quickstart``
71+
directory:
72+
73+
.. code-block:: bash
74+
75+
composer require mongodb/mongodb
76+
77+
After installing the library, include Composer's ``autoload.php`` file by adding the
78+
following line to ``quickstart.php``:
79+
80+
.. code-block:: bash
81+
82+
require_once __DIR__ . '/vendor/autoload.php';
83+
84+
After you complete these steps, you have a new project directory
85+
and the driver dependencies installed.
86+
87+
.. include:: /includes/get-started/troubleshoot.rst
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. note::
2+
3+
If you run into issues on this step, ask for help in the
4+
:community-forum:`MongoDB Community Forums <tag/php/>`
5+
or submit feedback by using the :guilabel:`Rate this page`
6+
tab on the right or bottom right side of this page.

source/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ MongoDB PHP Library
1111
:titlesonly:
1212

1313
Installation </tutorial/install-php-library>
14+
/get-started
1415
/tutorial
1516
/upgrade
1617
/reference

0 commit comments

Comments
 (0)