Download and Install
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:
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:
cd php-quickstart touch quickstart.php
cd php-quickstart type nul > quickstart.php
Install the MongoDB PHP Library
To install the MongoDB PHP Library, run the following command in your php-quickstart
directory:
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:
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.
Note
If you run into issues on this step, ask for help in the MongoDB Community Forums or submit feedback by using the Rate this page tab on the right or bottom right side of this page.