doctrine/couchdb-odm

此包已被弃用,不再维护。没有建议的替代包。

PHP Doctrine CouchDB 对象文档映射器(ODM)为 PHP 对象到 CouchDB 提供了透明的持久性。

v1.0.0-alpha3 2015-11-11 18:35 UTC

This package is auto-updated.

Last update: 2024-02-12 11:06:56 UTC


README

Build Status Scrutinizer Quality Score

Doctrine CouchDB 是 PHP 和 CouchDB 文档之间的映射器。它使用元数据映射模式将文档映射到普通的 PHP 对象,无需任何 ActiveRecord 模式或基类。

元数据映射可以通过注解、XML、YAML 或 PHP 实现。一个使用注解映射到 CouchDB 的示例 PHP 对象如下所示

/**
 * @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
}

使用此文档的简单工作流程如下

<?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();

您可以在每个 git checkout 的 sandbox/ 目录中尝试提供的沙盒,或阅读文档