A Document Mapper based on CouchDB
PHP
Latest commit 32aa02f Dec 23, 2016 @Ocramius Ocramius committed on GitHub Merge pull request #128 from mikeSimonson/update-travis-config
Updating the supported php versions
Permalink
Failed to load latest commit information.
bin Fixed autoloading for console tools Oct 14, 2015
lib Implemented shorthand version for version field mapping Apr 20, 2015
sandbox Fix an inconsistency in the Factory/Bootstrap API with CouchDBClient,… Jun 2, 2011
tests Update dependencies and skip Lucene tests. Nov 11, 2015
.gitignore Ignore composer.lock Nov 11, 2015
.gitmodules Add YAML Support and tests May 21, 2011
.scrutinizer.yml Added scrutinizer config Oct 23, 2015
.travis.yml
LICENSE Update LICENSE Oct 23, 2015
README.markdown
UPGRADE Cleanup #1 Jul 2, 2013
build.properties.dev
build.xml Gah, Small fixes in build.xml Jun 2, 2011
composer.json Merge pull request #118 from taion809/hotfix/adjust-minimum-php-version Nov 11, 2015
phpunit.xml.dist First milestone reworking annotations for CouchDB Oct 11, 2011

README.markdown

CouchDB ODM

Build Status Scrutinizer Quality Score

Doctrine CouchDB is a mapper between PHP and CouchDB documents. It uses a metadata mapping pattern to map the documents to plain old php objects, no ActiveRecord pattern or base class of any kind is necessary.

Metadata mapping can be done through annotations, xml, yaml or php. A sample PHP object that is mapped to CouchDB with annotations looks like this:

/**
 * @Document
 */
class Article
{
    /** @Id */
    private $id;

    /**
     * @Field(type="string")
     */
    private $topic;

    /**
     * @Field(type="string")
     */
    private $text;

    /**
     * @ReferenceOne(targetDocument="User")
     */
    private $author;

    // a bunch of setters and getters
}

A simple workflow with this document looks like:

<?php
$article = new Article();
$article->setTopic("Doctrine CouchDB");
$article->setText("Documentation");
$article->setAuthor(new Author("beberlei"));

// creating the document
$dm->persist($article);
$dm->flush();

$article = $dm->find("Article", 1234);
$article->setText("Documentation, and more documentation!");

// update the document
$dm->flush();

// removing the document
$dm->remove($article);
$dm->flush();

You can play around with the sandbox shipped in the sandbox/ folder of every git checkout or read the documentation at http://docs.doctrine-project.org/projects/doctrine-couchdb/en/latest/