bnbwebexpertise / laravel-couchdb
CouchDB Provider for the Laravel 5.5+ family. Includes doctrine/couchdb as a dependency in composer.json and sets up a Laravel and Eloquent-friendly Service Provider for you. Enjoy!
Requires
- php: >=7.0
- doctrine/couchdb: @dev
- illuminate/database: 5.6.x|5.5.x|5.4.x
- illuminate/support: 5.6.x|5.5.x|5.4.x
Requires (Dev)
- laravel/framework: 5.6.x|5.5.x|5.4.x
This package is auto-updated.
Last update: 2024-11-11 19:20:24 UTC
README
CouchDB database driver for Laravel 5.5+
Dependencies
laravel-couchdb uses doctrine/couchdb.
Installation
composer require bnbwebexpertise/laravel-couchdb
.
For laravel 5.5 and older, add the service provider in app/config/app.php
:
'Bnb\Laravel\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' => [ 'driver' => 'couchdb', 'type' => 'socket', 'host' => 'localhost', 'ip' => null, 'port' => 5984, 'dbname' => 'database', 'user' => 'username', 'password' => 'password', 'ssl' => false, 'logging' => false, 'timeout' => 15, ],
Examples
/** * @var \Bnb\Laravel\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.