Skip to content

tandusrl/Chill

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chill - PHP Library for CouchDb

This is a fork

This is just an internal fork in order to have better error handling and have more flexibility

Chill is a simple and efficient CouchDb client library for PHP. Released under the BSD 2 Clause Licence and made available via Composer/Packagist.

Current Build Status:

Build Status

Example usage

Retrieve a single document by ID:

$chill = new Chill\Client('localhost', 'my_database');
$doc = $chill->get('8128173972d50affdb6724ecbd00d9fc');
print $doc['_id'];

Retrieve the results of a view as Chill Document objects:

$chill = new Chill\Client('localhost', 'my_database');
$docs = $chill->asDocuments()->getView('mydesign', 'myview', array('key1', 'key2'));

foreach ($docs as $doc) {
    print $doc->_id . PHP_EOL;
}

Retrieve and update a document

$chill = new Chill\Client('localhost', 'my_database');
$doc = $chill->get('8128173972d50affdb6724ecbd00d9fc');
$doc->title = 'Changing my doc.';
$doc->save();

New stuff in the fork

Connect with username and password

// yes, now you can remove admin party
$chill = new Chill\Client('localhost', 'my_database', 'username', 'password');

Get raw form of a document (eg. get a design document)

$doc = $chill->getRawDocument('_design/yolo');

Create a new database

// connect with the new database name not already created
$chill = new Chill\Client('localhost', 'my_database');
$chill->createDatabase('my_database');
// enjoy query in your new databases

HTTP status in most error reporting

With thanks to