-
Notifications
You must be signed in to change notification settings - Fork 34
DOCSP-41952: Download and Install #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
6418d93
5ef0ac6
005d830
cc32aa5
186f149
48abf5f
0582736
4d951ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ build/* | |
build | ||
*~ | ||
*giza.log | ||
source/* | ||
backups/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.. _php-get-started: | ||
|
||
================================ | ||
Get Started with the PHP Library | ||
================================ | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 2 | ||
:class: singlecol | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: tutorial | ||
|
||
.. meta:: | ||
:description: Learn how to create an app to connect to MongoDB deployment by using the PHP library. | ||
:keywords: quick start, tutorial, basics | ||
|
||
.. toctree:: | ||
|
||
/get-started/download-and-install/ | ||
|
||
Overview | ||
-------- | ||
|
||
The {+php-library+} is a high-level abstraction for the MongoDB PHP extension, which | ||
you can use to connect to MongoDB and interact with data stored in your deployment. | ||
This guide shows you how to create an application that uses the {+php-library+} to | ||
connect to a MongoDB cluster hosted on MongoDB Atlas and query data in your cluster. | ||
|
||
.. tip:: | ||
|
||
MongoDB Atlas is a fully managed cloud database service that hosts your MongoDB | ||
deployments. You can create your own free (no credit card required) MongoDB Atlas | ||
deployment by following the steps in this guide. | ||
|
||
Follow this guide to connect a sample PHP application to a MongoDB Atlas | ||
deployment. If you prefer to connect to MongoDB using a different driver or | ||
programming language, see our :driver:`list of official drivers <>`. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,87 @@ | ||||||
.. _php-download-and-install: | ||||||
|
||||||
==================== | ||||||
Download and Install | ||||||
==================== | ||||||
|
||||||
.. facet:: | ||||||
:name: genre | ||||||
:values: tutorial | ||||||
|
||||||
.. meta:: | ||||||
:keywords: setup, composer, installation, code example | ||||||
|
||||||
.. procedure:: | ||||||
:style: connected | ||||||
|
||||||
.. step:: Install dependencies | ||||||
|
||||||
Before you begin developing, ensure that you have the following | ||||||
dependencies installed on your local machine: | ||||||
|
||||||
- `PHP <https://www.php.net/manual/en/install.php>`__ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Which version of PHP/Composer are necessary? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added! |
||||||
- `Composer <https://getcomposer.org/download/>`__ | ||||||
|
||||||
.. step:: Install the MongoDB extension | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
Run the following command to install the ``mongodb`` PHP extension: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
sudo pecl install mongodb | ||||||
|
||||||
.. step:: Update your PHP configuration file | ||||||
|
||||||
To enable the ``mongodb`` extension, add the following line to the top of | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
your ``php.ini`` file: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
extension=mongodb.so | ||||||
|
||||||
.. tip:: | ||||||
|
||||||
You can locate your ``php.ini`` file by running the following command | ||||||
from your shell: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or to create consistency: "running the following command in your shell" |
||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
php --ini | ||||||
|
||||||
.. step:: Create a project directory | ||||||
|
||||||
From your root directory, run the following command in your shell to create | ||||||
a directory called ``php-quickstart`` for this project: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
mkdir php-quickstart | ||||||
|
||||||
Run the following commands to create a ``quickstart.php`` application file in | ||||||
the ``php-quickstart`` directory: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
cd php-quickstart | ||||||
touch quickstart.php | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: To my knowledge, the touch command only works on linux/mac machines. This thread: https://stackoverflow.com/questions/30011267/create-an-empty-file-on-the-commandline-in-windows-like-the-linux-touch-command provides alternatives that I think work on both Windows and Linux, unless we want to specify that this guide is only valid for mac/linux machines |
||||||
|
||||||
.. step:: Install the {+php-library+} | ||||||
|
||||||
To install the {+php-library+}, run the following command from your ``php-quickstart`` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
directory: | ||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
composer require mongodb/mongodb | ||||||
|
||||||
After installing the library, include Composer's ``autoload.php`` file by adding the | ||||||
following line to ``quickstart.php``: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q: Do the users add this line at the end of the file, or at the beginning/does placement of the line matter? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should go at the top |
||||||
|
||||||
.. code-block:: bash | ||||||
|
||||||
require_once __DIR__ . '/vendor/autoload.php'; | ||||||
|
||||||
After you complete these steps, you have a new project directory | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
and the library dependencies installed. | ||||||
|
||||||
.. include:: /includes/get-started/troubleshoot.rst |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.. note:: | ||
|
||
If you run into issues on this step, ask for help in the | ||
:community-forum:`MongoDB Community Forums <tag/php/>` | ||
or submit feedback by using the :guilabel:`Rate this page` | ||
tab on the right or bottom right side of this page. |
Uh oh!
There was an error while loading. Please reload this page.