-
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
Merged
norareidy
merged 8 commits into
mongodb:php-standardization
from
norareidy:DOCSP-41952-download-install
Aug 21, 2024
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6418d93
DOCSP-41952: Download and Install
norareidy 5ef0ac6
edits
norareidy 005d830
toc, fixes
norareidy cc32aa5
AS feedback
norareidy 186f149
AS feedback 2
norareidy 48abf5f
typo
norareidy 0582736
JT feedback
norareidy 4d951ea
Merge remote-tracking branch 'upstream/php-standardization' into DOCS…
norareidy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ build/* | |
build | ||
*~ | ||
*giza.log | ||
source/* | ||
backups/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 <>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||||||
norareidy marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
.. 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 following commands | ||||||
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. Sorry, just noticed this! Quick fix:
Suggested change
|
||||||
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.