toiine/couchbasebundle

Symfony2扩展,用于操作Couchbase文档。

安装次数: 1,372

依赖项: 0

建议者: 0

安全: 0

星标: 8

关注者: 5

分支: 3

开放问题: 1

类型:symfony-bundle

dev-develop 2013-07-24 00:00 UTC

This package is not auto-updated.

Last update: 2024-09-28 23:20:03 UTC


README

Symfony2扩展,用于操作Couchbase文档。

Build Status Build Status SensioLabsInsight

安装

通过Packagist安装扩展是最快和最简单的方法。以下是步骤:

步骤1: Composer require

$ php composer.phar require "toiine/couchbasebundle":"dev-master"

步骤2: 在内核中启用扩展

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Toiine\CouchbaseBundle\ToiineCouchbaseBundle(),
        // ...
    );
}

配置

在Resources/config/couchbase.yml.dist中有一个示例配置文件。

connections:
  conn1:
    # default is "localhost"
    # host:
    # default is 8091
    # port:
    username: admin
    password: admin
    bucket: default
  conn2:
    host: couchbase.tld
    port: 8092
    username: couchbase
    password: cOuchb4s3
    bucket: bucket2

服务

编译器过程将根据配置文件生成服务。

php app/console container:debug | grep couchbase

您可以使用toiine_couchbase.<connectionName>服务来操作您的文档。

注意:其他服务的文档将很快提供。

使用方法

<?php

namespace Acme\HelloBundle\Controller;

use Symfony\Component\HttpFoundation\Response;

class DocController
{
    public function getDocumentAction($key)
    {
        $couchbase = $this->get('toiine_couchbase.conn1');
        
        // Get a doc from couchbase
        $doc = $couchbase->get($key);
        
        // Push a doc to couchbase
        $couchbase->set($key, $doc);
        
        // Delete a doc from couchbase
        $couchbase->delete($key);
        
        ...
    }
}

待办事项

  • 在Web调试工具栏中添加一个分析面板:查看调用及其耗时
  • 集成Jms Serializer:像Doctrine EntityManager一样通过Couchbase操作实体