CouchDB database driver for Laravel 4

dev-master 2015-04-10 03:05 UTC

This package is not auto-updated.

Last update: 2022-06-25 03:36:23 UTC


CouchDB database driver for Laravel 4


laravel-couchdb uses doctrine/couchdb-client. This package will be automatically downloaded for you via composer.


Add the package to your composer.json and run composer update.

    "require": {
        "rbewley4/laravel-couchdb": "dev-master"

Add the service provider in app/config/app.php:


The service provider will register a couchdb database extension with the original database manager. There is no need to register additional facades or objects. When using couchdb connections, Laravel will automatically provide you with the corresponding couchdb objects.


Change your default database connection name in app/config/database.php:

'default' => 'couchdb',

And add a new couchdb connection:

'couchdb' => array(
    'driver'   => 'couchdb',
    'type'     => 'socket',
    'host'     => 'localhost',
    'ip'       => null,
    'port'     => 5984,
    'dbname'   => 'database',
    'user'     => 'username',
    'password' => 'password',
    'logging'  => false,

Eloquent, Query Builder, Schema Builder

Sorry, we do not support these components at this time.


laravel-couchdb provides you with direct access to a CouchDBClient object, and expects you to use it for all CouchDB interaction.

For more information on CouchDBClient, see doctrine/couchdb-client.

Get handle to CouchDBClient

 * @var \Rbewley4\Laravel\Couchdb\CouchdbConnection
$connection = DB::connection('couchdb');

 * @var \Doctrine\CouchDB\CouchDBClient
$couchdb = $connection->getCouchDB();

Note: you can invoke methods on CouchDBClient by invoking them on CouchdbConnection. This is accomplished via the use of magic methods.

Create/Update/Find Document

Here we demonstrate three different operations that you can perform on CouchDB, and we show three different ways that you can invoke these methods:

$connection = DB::connection('couchdb');
$couchdb = $connection->getCouchDB();

list($id, $rev) = $connection->postDocument(array('foo' => 'bar'));
$couchdb->putDocument(array('foo' => 'baz'), $id, $rev);
$doc = DB::connection('couchdb')->findDocument($id);

Note that all three methods can be called on $connection or $couchdb.