It Support Development ): Install Mongodb Driver For Php On

  

Join the DZone community and get the full member experience.

Create a thread on Plesk UserVoice to vote for including MongoDB driver into Plesk PHP. Manual extension installation: Warning: If /tmp is mounted with no-exec option, PECL will be unable to install.

Join For Free

Nearly 3 years ago I discovered a new database that literally changed my life. I know, that’s a pretty bold claim, but it’s true. While leading the engineering team at OpenSky I faced a problem I was well familiar with. How to build a e-commerce product that: 1. Provided performance and scale 2. Handled many verticals and 3. Provided proper indexing on key attributes. In search for a better solution to this problem I encountered MongoDB. I soon experienced a realization that not only was MongoDB the solution to my e-commerce challenge, but fundamentally would change the way all development happens.

It Support Development ) Install Mongodb Driver For Php On Windows

It support development ) install mongodb driver for php on windowsIt support development ): install mongodb driver for php on windows

This is the first in a series of posts on MongoDB and PHP that will both explain why you should use MongoDB and teach you how. In this first post we will begin with installing the necessary servers and drivers to be able to use MongoDB with PHP.

MongoDB (from “humongous”) is a scalable, high-performance, open source document database written in C++. While many people hear ‘document database’ and they think of pdf and doc files, the term document really is analogous to an array in PHP. Effectively MongoDB is a persistent storage engine for PHP arrays and objects (as well as any other language) with read through, write thorough memory caching, true high availability, an elegant interface and seamless horizontal scale. Once you write an application with MongoDB you’ll wonder why anyone uses anything else.

Installing MongoDB is as easy as using your package installer to install the package. Whether you are using Linux, Mac or Windows, it’s easy to install MongoDB.

The MongoDB Manual has a complete guide on installing MongoDB for all the different systems it supports.

The 1st step is to install PECL. PECL is the default installer for all C extensions to the PHP driver. Usually if you have PHP installed you already have PECL. You may be surprised to find that Mac OS X doesn’t include PECL, in the event you don’t have PECL already, here’s how to install it.

Installing PEAR & PECL

  1. cd /usr/lib/php
  2. sudo php install-pear-nozlib.phar
  3. Edit /etc/php.ini and find the line: ;include_path = '.:/php/includes'
    change it to: include_path = '.:/usr/lib/php/pear'
    make sure to remove the ‘;’ at the beginning of that line.
  4. sudo pear channel-update pear.php.net
  5. sudo pecl channel-update pecl.php.net
  6. sudo pear upgrade-all

Once you have PECL installed the process is easy to install the Mongo DB driver. A simple

It Support Development ) Install Mongodb Driver For Php On Ubuntu

is all it takes. Once that’s completed you’ll need to add the extension line to your PHP.ini file and restart Apache. For *nix the line is

Once Apache is restarted you should confirm that the MongoDB extension is installed by checking php_info(). A shortcut for this is

Creating a connection to MongoDB is pretty easy. We create a new Mongo object and pass in the URI of the server you’re connecting to. The following example will show you how to connect to a Mongo DB server, create a db and a collection and insert a single record into that collection.

Like This Article? Read More From DZone

Mongo Db Driver For Php

Published at DZone with permission of Steve Francia , DZone MVB. See the original article here.

It Support Development ) Install Mongodb Driver For Php Only

Opinions expressed by DZone contributors are their own.