gmg/laravel5-couchdb

There is no license information available for the latest version (0.0.3) of this package.

CouchDB Driver for the Laravel 5 family. Includes doctrine/couchdb as a dependency in composer.json and sets up a Laravel and Eloquent-friendly Service Provider for you. Enjoy!

0.0.3 2017-10-27 14:55 UTC

This package is not auto-updated.

Last update: 2024-11-13 04:32:08 UTC


README

CouchDB database driver for Laravel 5

Dependencies

laravel5-couchdb uses doctrine/couchdb.

Installation

composer require gmg/laravel5-couchdb.

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

'gmg\Laravel5\Couchdb\CouchdbServiceProvider',

When using couchdb connections, Laravel will automatically provide you with the corresponding couchdb objects.

Configuration

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,
),

Examples

/**
 * @var \gmg\Laravel5\Couchdb\CouchdbConnection
 */
$connection = DB::connection('couchdb');

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

Create/Update/Find Document example

$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);

All three methods can be called on $connection or $couchdb.