Skip to content

Getting Started

Thomas Cocchiara edited this page Jan 5, 2018 · 5 revisions

Next

Getting Started

To use the library you need php7 or superior and you need to install the mongodb pecl library: https://pecl.php.net/package/mongodb

Command:

$ sudo pecl install mongodb

Also you need the composer executable to install all the dependencies: https://getcomposer.org/

The next step is to prepare the library to be used inside your own project.

Using Composer

The easiest way is to add the repository to your composer.json.

To do so run the following:

$ composer require thomas-squall/php7-mongo-driver

To your require field of composer.json.

If everything went good (and it should) you now just need to load you composer autoload placed inside the vendor folder.

The final code should look like this:

<?php
include_once "vendor/autoload.php";

Now you are ready to go :D

Downloading the package

If you not using (or planning to use) the composer you can still download the package and put yourself somewhere in your project, I've prepared an autoload.php file for this.

Once in the project use the code:

<?php
include_once "path_to_the_php_7_mongo_driver/autoload.php";

NOTE: even if you are not using composer to install the library you still need it to install the library dependencies.

Install the dependencies

Move into the folder where you placed the library and simply run:

$ composer install

Now you are done :D

Next