Skip to content

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

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ build/*
build
*~
*giza.log
source/*
backups/*
1 change: 1 addition & 0 deletions snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ toc_landing_pages = [
"/reference/class/MongoDBModelCollectionInfo",
"/reference/class/MongoDBModelDatabaseInfo",
"/reference/class/MongoDBModelIndexInfo",
"/get-started",
]

[substitutions]
Expand Down
41 changes: 41 additions & 0 deletions source/get-started.txt
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 <>`.
87 changes: 87 additions & 0 deletions source/get-started/download-and-install.txt
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>`__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Which version of PHP/Composer are necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added!

- `Composer <https://getcomposer.org/download/>`__

.. step:: Install the MongoDB extension
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. step:: Install the MongoDB extension
.. step:: Install the MongoDB PHP extension


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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To enable the ``mongodb`` extension, add the following line to the top of
To enable the ``mongodb`` extension in your PHP configuration file, add the following line to the top of

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:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
from your shell:
the following shell command:

Copy link
Collaborator

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To install the {+php-library+}, run the following command from your ``php-quickstart``
To install the {+php-library+}, run the following command in your ``php-quickstart``

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``:
Copy link
Collaborator

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After you complete these steps, you have a new project directory
After you complete these steps, you have a new project directory, a new application file,

and the library dependencies installed.

.. include:: /includes/get-started/troubleshoot.rst
6 changes: 6 additions & 0 deletions source/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.
1 change: 1 addition & 0 deletions source/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ MongoDB PHP Library
:titlesonly:

Installation </tutorial/install-php-library>
Get Started </get-started>
/tutorial
/upgrade
/reference
Expand Down