php-on-couch / php-on-couch
CouchDB NoSQL database access in PHP
Installs: 104 777
Dependents: 4
Suggesters: 0
Security: 0
Stars: 100
Watchers: 12
Forks: 102
Open Issues: 7
Requires
- php: >=5.6.0
Requires (Dev)
- dev-master
- 4.0.2
- 4.0.1
- 4.0.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.6a
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 1.6.1.x-dev
- 1.6.1
- 1.0.1-p2
- 1.0.1-p1
- dev-feature/enhance-auth
- dev-feature/remove-php-dot-env
- dev-feature/update-changelist-for-2.0.7
- dev-fix/socket-adapter
- dev-fix/continuousQuery
- dev-feature/support-conflicts-for-find
- dev-fix/find-as-array
- dev-feature/scheduler
- dev-forked_master
This package is auto-updated.
Last update: 2023-11-12 01:33:35 UTC
README
🔥For the complete documentation, visit http://php-on-couch.readthedocs.io 🔥
Table of content
- Introduction
- What's new
- Changes
- Installation and testing
- Components and documentation
- Quick-start guide
- Example
- Community
Introduction
PHP On Couch provides an easy way to work with your CouchDB documents with PHP.
Supports PHP 5.6 and higher 🚀
Recent changes
For the complete change list, head over here
Installation and testing
Install the library using composer : composer require php-on-couch/php-on-couch
.
You can find more detailed informations about installation here.
To test the the application, see this topic.
Components and documentation
For the full API document, please visite this link
Example
For full examples, refer to the database example or the document example.
At first, you need to import the main components through their namespace. If you use composer, I suggest you to use their autoload wich is easy to setup. Otherwise, you can use your own autoload function or a basic require with some namespace escaping.
use PHPOnCouch\CouchClient; //The CouchDB client object
Here's an example for basic operations
// Set a new connector to the CouchDB server $client = new CouchClient('http://my.couch.server.com:5984', 'my_database'); // document fetching by ID $doc = $client->getDoc('some_doc_id'); // updating document $doc->newproperty = array("hello !", "world"); try { $client->storeDoc($doc); } catch (Exception $e) { echo "Document storage failed : " . $e->getMessage() . "<BR>\n"; }
Here's a quick example of how to fetch a view
// view fetching, using the view option limit try { $view = $client->limit(100)->getView('orders', 'by-date'); } catch (Exception $e) { echo "something weird happened: " . $e->getMessage() . "<BR>\n"; }
Finally, how to use the CouchDocument class.
//using couch_document class : $doc = new CouchDocument($client); $doc->set(array('_id' => 'JohnSmith', 'name' => 'Smith', 'firstname' => 'John')); //create a document and store it in the database echo $doc->name; // should echo "Smith" $doc->name = "Brown"; // set document property "name" to "Brown" and store the updated document in the database
Community
Contributions
Feel free to make any contributions. All contributions must follow the code style and must also comes with valid and complete tests.
Help is really appreciated to complete add more tests.
Feedback
Don't hesitate to submit feedback, bugs and feature requests ! Our contact address is phponcouch@gmail.com