Skip to content

Commit cc82b21

Browse files
committed
Improve README instructions
1 parent 18a5b19 commit cc82b21

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,43 @@ A lightweight library to make it very easy to work with [CouchDB](http://couchdb
99
It's recommended to install this library using [Composer](https://getcomposer.org/):
1010

1111
```
12-
composer require ibm-watson-data-lab/php-couchdb:dev-master
12+
composer require ibm-watson-data-lab/php-couchdb:~0.1@beta
1313
```
1414

1515
## Usage
1616

17-
A simple use case to check you can connect to CouchDB and check what version of CouchDB it's running.
17+
Here's the tl;dr of how to begin. For more detailed examples, see the [wiki](https://github.com/ibm-watson-data-lab/php-couchdb/wiki) and/or generate the API docs with `composer docs`
1818

1919
```php
2020
<?php
2121

2222
require "vendor/autoload.php";
2323

24+
// connect to CouchDB (does make a call to check we can connect)
2425
$server = new \PHPCouchDB\Server(["url" => "http://localhost:5984"]);
25-
echo $server->getVersion();
26+
27+
// get a list of databases; each one is a \PHPCouchDB\Database object
28+
$databases = $server->getAllDbs();
29+
30+
// work with the "test" database (also a \PHPCouchDB\Database object)
31+
$test_db = $server->useDb(["name" => "test", "create_if_not_exists" => true]);
32+
33+
// add a document - you may specify the "id" here if you like
34+
$doc = $test_db->create(["name" => "Alice", "interests" => ["eating", "wondering"]]);
35+
36+
// inspect the document
37+
print_r($doc);
38+
39+
// update the document - a NEW document is returned by this operation, showing the server representation of the document
40+
$doc->friends[] = "Cheshire Cat";
41+
$updated_doc = $doc->update();
42+
43+
// done? Delete the doc
44+
$updated_doc->delete();
2645
```
2746

47+
For more examples, conflict handling and really everything else, see more detailed documentation on the wiki.
48+
2849
## For Developers
2950

3051
Contributions and issues are all _very_ welcome on this project - and of course we'd love to hear how you're using the library in your own projects.

0 commit comments

Comments
 (0)