Symfony2 bundle to manipulate Couchbase Documents.
Installing the bundle via packagist is the quickest and simplest method of installing the bundle. Here are the steps:
$ php composer.phar require "choiceforyou/couchbasebundle":"dev-master"
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Choiceforyou\CouchbaseBundle\ChoiceforyouCouchbaseBundle(),
// ...
);
}
There is a sample configuration file in 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
A compiler pass will generate services according to the configuration file
php app/console container:debug | grep couchbase
Service name | Class |
---|---|
choiceforyou_couchbase.conn1 | Couchbase |
choiceforyou_couchbase.conn2 | Couchbase |
You can use choiceforyou_couchbase.<connectionName> services to manipulate you documents.
NB: documentation on other services will come soon.
<?php
namespace Acme\HelloBundle\Controller;
use Symfony\Component\HttpFoundation\Response;
class DocController
{
public function getDocumentAction($key)
{
$couchbase = $this->get('choiceforyou_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);
...
}
}
- add a profiling panel in the web debug toolbar : see the calls and the time they took
- integrate Jms Serializer : manipulate Entities through Couchbase the same way as Doctrine EntityManager