From the course: MongoDB Essential Training

Unlock the full course today

Join today to access over 23,200 courses taught by industry experts.

Connecting with PHP

Connecting with PHP

- [Instructor] For PHP, we'll be using MongoDB's native driver. To use the PHP driver, you'll need both the extension and the library installed. The extension itself provides minimal API for the core driver functionality, allowing you to connect to the database and run queries. The library, however, models the client, database, and collection objects. Okay, so let's install this. First, we are going to use pecl to install MongoDB. In my case, that is already installed. Next, I'm going to run php --ini to get the configuration file location. Okay, with that, I am going to echo the extension mongodb.so into that file. All right, that's the extension installed. Now we're going to install the library, and for that, we are going to use Composer. To make sure you've got Composer installed, just run composer --version. If you don't get back a version number, you're going to first have to install Composer before resuming.…

Contents