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 all 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: 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
24 changes: 22 additions & 2 deletions source/get-started.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,33 @@ Get Started with the PHP Library
.. 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/
/get-started/create-a-deployment/
/get-started/create-a-connection-string/
/get-started/next-steps/
/get-started/next-steps/

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 <>`.

102 changes: 102 additions & 0 deletions source/get-started/download-and-install.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
.. _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>`__ version 7.4 or later
- `Composer <https://getcomposer.org/download/>`__ version 2.0 or later

.. 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 in your PHP configuration file, add the
following line to the top of your ``php.ini`` file:

.. code-block:: none

extension=mongodb.so

.. tip::

You can locate your ``php.ini`` file by 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

Select the tab corresponding to your operating system and run the following commands
to create a ``quickstart.php`` application file in the ``php-quickstart`` directory:

.. tabs::

.. tab:: macOS / Linux
:tabid: create-file-mac-linux

.. code-block:: bash

cd php-quickstart
touch quickstart.php

.. tab:: Windows
:tabid: create-file-windows

.. code-block:: bash

cd php-quickstart
type nul > quickstart.php

.. step:: Install the {+php-library+}

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 code to the top of your ``quickstart.php`` file:

.. code-block:: php

<?php

require_once __DIR__ . '/vendor/autoload.php';

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
3 changes: 1 addition & 2 deletions source/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ MongoDB PHP Library
.. toctree::
:titlesonly:

Installation </tutorial/install-php-library>
Get Started </get-started>
/tutorial
/upgrade
Expand Down Expand Up @@ -38,7 +37,7 @@ New to the PHP Library?
If you have some experience with MongoDB but are new to the PHP library, the
following pages should help you get started:

- :doc:`/tutorial/install-php-library`
- :ref:`php-download-and-install`

- :doc:`/tutorial/connecting`

Expand Down
99 changes: 0 additions & 99 deletions source/tutorial/install-php-library.txt

This file was deleted.

Loading