Package Data | |
---|---|
Maintainer Username: | defenestrator |
Maintainer Contact: | jeremy@copacetic.co (Jeremy Anderson) |
Package Create Date: | 2016-01-12 |
Package Last Update: | 2016-11-11 |
Language: | PHP |
License: | Unknown |
Last Refreshed: | 2024-12-20 03:01:34 |
Package Statistics | |
---|---|
Total Downloads: | 174 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 16 |
Total Watchers: | 5 |
Total Forks: | 10 |
Total Open Issues: | 0 |
CouchDB database driver for Laravel 5
laravel5-couchdb uses doctrine/couchdb.
composer require defenestrator/laravel5-couchdb
.
Add the service provider in app/config/app.php
:
'Defenestrator\Laravel5\Couchdb\CouchdbServiceProvider',
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,
),
/**
* @var \Defenestrator\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.