How to use mongoDB in CodeIgniter

If you want to use mongoDB in your codeIgniter project as a database then this post may be helpful for you.

There are some simple steps to configure mongoDB in your project.

1.  Install PECL pakcage.

For this you can take help from official PHP site –

2. Download CodeIgniter library.

You have to download a library which helps to create connection with mongoDB

3. Install mongoDB.

You have to install mongoDB database in your system. According to your opearting system download installable file from and install.

4. Set up library.

Extract library and you will get a config file which you need to place in application/config folder and a library file which shoulb be placed in application/libraries folder. In mongoDB config file enter your credentials like


5. Load library.

As a normal library whenever you want to use mongoDB in your project, you will need to load mongoDB library. For this you can use this code.


Here mongo_db_conn is a connection which can be used further for any CRUD purpose.

Mostly all methods are same as simple database connection.  For detailed documentation see


Here is my video for same purpose, may be it can help you to troubleshoot some problems.

Please follow and like us:

1 Comment

  1. Nice post. thanks.

Leave a Reply