PHP code example of bachi / couchdb

1. Go to this page and download the library: Download bachi/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/ */

    

bachi / couchdb example snippets


$client = new \GuzzleHttp\Client(['base_uri' => 'http://localhost:5984', 'http_errors' => false]);
$connection = new \CouchDB\Connection($client);

$database = $conn->createDatabase('foobar');
// or with magic method
$database = $conn->foobar;

$database = $conn->selectDatabase('foobar');
// or with magic method
$database = $conn->foobar;

if (true === $conn->hasDatabase('foobar')) {
    $conn->dropDatabase('foobar');
}
// or with magic methods
if (isset($conn->foobar)){
    unset($conn->foobar);
}