Here I will explain how to use CouchDB NoSQL database on CodeIgniter using PHP On Couch open source library (Data Access Library to access a CouchDB server with PHP).
PHP On Couch tries to provide an easy way to work with your CouchDB documents with PHP.
Here I assume you know PHP and CodeIgniter. If don’t go through http://ellislab.com/codeigniter Its running on your system.
Here is How to use Couchdb NoSQL database on CodeIgniter?
First Download PHP On Couch from here:
https://github.com/dready92/PHP-on-Couch
Setup instructions:
https://github.com/dready92/PHP-on-Couch/tree/master/frameworks/ci
1.) copy the PHP on Couch classes
copy all from /PHP-on-Couch-master/lib/
to /CodeIgniter_2.1.4/application/libraries/
2.) copy the PHP on Couch CI classes
copy from /PHP-on-Couch-master/frameworks/ci/libraries/
to /CodeIgniter_2.1.4/application/libraries/
3.) copy the config/couchdb.php file inside the config folder of your application/libraries/
copy from /PHP-on-Couch-master/frameworks/ci/config
to /CodeIgniter_2.1.4/application/config/
4.) edit the config/couchdb.php file to set the two configuration options couch_dsn and couch_database :
$config[‘couch_dsn’] = “http://localhost:5984/“;
$config[‘couch_database’] = “my_wonderful_db”;
5.) if you want the couchdb object to be autoloaded, edit the config/autoload.php file of your CodeIgniter application and add “couchdb” to the list of libraries to autoload
$autoload[‘libraries’] = array(‘couchdb’);
6.) Thats it!
References:
https://github.com/dready92/PHP-on-Couch/blob/master/doc/couch_client-database.md
https://github.com/dready92/PHP-on-Couch/blob/master/doc/couch_client-document.md
https://github.com/dready92/PHP-on-Couch/tree/master/doc
http://wiki.apache.org/couchdb/Getting_started_with_PHP
http://en.wikipedia.org/wiki/CouchDB
http://guide.couchdb.org/editions/1/en/index.html
Leave a comment