Developed with love by KnpLabs Hire us for your project!
44

DoctrineCouchDBBundle

by doctrine

Symfony Bundle for DoctrineCouchDB

Doctrine CouchDB Bundle

This bundle integrates Doctrine CouchDB ODM and Clients into Symfony2.

STABILITY: Alpha

Installation

  • composer require doctrine/couchdb-odm-bundle
  • Add Doctrine\Bundle\CouchDBBundle\DoctrineCouchDBBundle to your Kernel#registerBundles() method
  • If you do not use composer, do not forget to add autoloader for the Doctrine\CouchDB, Doctrine\ODM\CouchDB and Doctrine\Bundle namespaces

To use the annotations, register them in your app/autoload.php file:

use Doctrine\Common\Annotations\AnnotationRegistry;
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));

Documentation

See the Doctrine CouchDB ODM documentation for more information.

Configuration

The configuration is similar to Doctrine ORM and MongoDB configuration for Symfony2 as its based
on the AbstractDoctrineBundle aswell:

doctrine_couch_db:
  client:
    dbname: symfony
  odm:
    auto_mapping: true

To dump the configuration reference of this bundle

php app/console config:dump-reference doctrine_couch_db

Annotations

An example of how to use annotations with CouchDB and Symfony:

<?php
namespace Acme\DemoBundle\CouchDocument;

use Doctrine\ODM\CouchDB\Mapping\Annotations as CouchDB;

/**
 * @CouchDB\Document
 */
class User
{
    /** @CouchDB\Id */
    private $id;
}

Services

You can access to CouchDB services:

<?php

namespace Acme\DemoBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class DefaultController extends Controller
{
    public function indexAction()
    {
        $client = $this->container->get('doctrine_couchdb.client.default_connection');
        $documentManager = $this->container->get('doctrine_couchdb.odm.default_document_manager');
    }
}

View directories

In @YourBundle/Resources/couchdb/ you can add design documents and corresponding views and have Doctrine
CouchDB register them up automatically. For example if you had a design doc "foo" and a view "bar" you could
add the following files and directories:

Resources/couchdb/
└── foo/
    └── views/
        └── bar/
            ├── map.js
            └── reduce.js

You can then update this design document from the CLI by calling:

./app/console doctrine:couchdb:update-design-doc foo

Where foo is the name of the design document.

Copyright (c) 2010-2012 Doctrine

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

This software consists of voluntary contributions made by many individuals
and is licensed under the LGPL. For more information, see
<http://www.doctrine-project.org>.
doctrine_couch_db:
client: # Required
default_connection: ~
connections:

# Prototype
name:
dbname: ~
host: localhost
port: 5984
user: ~
password: ~
ip: ~
logging: false
type: ~
odm:
default_document_manager: ~
auto_generate_proxy_classes: false
proxy_dir: %kernel.cache_dir%/doctrine/CouchDBProxies
proxy_namespace: CouchDBProxies
document_managers:

# Prototype
name:
metadata_cache_driver:
type: array # Required
host: ~
port: ~
instance_class: ~
class: ~
namespace: ~
connection: ~
auto_mapping: false
mappings:

# Prototype
name:
mapping: true
type: ~
dir: ~
alias: ~
prefix: ~
is_bundle: ~
design_documents:

# Prototype
name:
className: ~
options: ~
lucene_handler_name: false
uuid_buffer_size: 20
view_name: symfony
all_or_nothing_flush: true
  • Merge pull request #41 from Tatsh/add-namespace-option
    By stof, 2 years ago
  • Update test for cache driver "namespace" key
    By Tatsh, 2 years ago
  • Add custom namespace option
    By Tatsh, 2 years ago
  • Merge pull request #39 from dbu/mapping-compiler-alias
    By stof, 2 years ago
  • add support for bundle namespace alias
    By dbu, 2 years ago
  • Fix bug in unserialize proxy autoloader
    By beberlei, 3 years ago
  • Merge pull request #24 from dbu/patch-1
    By beberlei, 3 years ago
  • Merge pull request #27 from dbu/doctrine-register-mappings-pass
    By beberlei, 3 years ago
  • Merge pull request #34 from ROMOPAT/patch-1
    By beberlei, 3 years ago
  • Auto Generate Proxy classes
    By beberlei, 3 years ago
  • Update CompactDatabaseCommand.php
    By ROMOPAT, 3 years ago
  • Update CompactDatabaseCommand.php
    By ROMOPAT, 3 years ago
  • Update ViewCleanupCommand.php
    By ROMOPAT, 3 years ago
  • Update UpdateDesignDocCommand.php
    By ROMOPAT, 3 years ago
  • Update ReplicationStartCommand.php
    By ROMOPAT, 3 years ago
  • Update ReplicationCancelCommand.php
    By ROMOPAT, 3 years ago
  • Update MigrationCommand.php
    By ROMOPAT, 3 years ago
  • Update CompactViewCommand.php
    By ROMOPAT, 3 years ago
  • Update CompactDatabaseCommand.php
    By ROMOPAT, 3 years ago
  • Update composer.json
    By beberlei, 3 years ago
  • no need to alias
    By dbu, 3 years ago
  • use registerLoader in README
    By dbu, 3 years ago
  • forgot the annotation driver
    By dbu, 3 years ago
  • add mappings compiler pass
    By dbu, 3 years ago
  • Update README.md
    By dbu, 3 years ago
  • Merge pull request #25 from dbu/works-with-symfony2.2
    By stof, 3 years ago
  • bundle seems to work with symfony 2.2 too
    By dbu, 3 years ago
  • include with composer
    By dbu, 3 years ago
  • Merge pull request #18 from saem/master
    By beberlei, 3 years ago
  • Merge pull request #22 from tolry/patch-1
    By beberlei, 3 years ago