Giter VIP home page Giter VIP logo

Latest Stable VersionLatest Unstable VersionBuild StatusDocumentation StatusScrutinizer Code QualitycodecovLicense

πŸ”₯For the complete documentation, visit http://php-on-couch.readthedocs.io πŸ”₯

Table of content

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

Gitter chat

Don't hesitate to submit feedback, bugs and feature requests ! Our contact address is [email protected]

PHPOnCouch's Projects

php-on-couch icon php-on-couch

Data Access Library to access a CouchDB server with PHP.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.