PHP code example of gmg / laravel5-couchdb

1. Go to this page and download the library: Download gmg/laravel5-couchdb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gmg / laravel5-couchdb example snippets


'gmg\Laravel5\Couchdb\CouchdbServiceProvider',

'default' => 'couchdb',

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

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

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

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