A bundle for couchbase. Just basic stuff in the first place, that all will come to use ;)

License: MIT

Language: PHP


This bundle creates a Symfony2 integration for Couchbase. It currently adds commands to make it easier to automate import and export of design documents, stored in Couchbase and adds all Couchbase actions to the timeline in the Symfony2 profiler.

This bundle requires a specific version of the php-couchbase extension:

PECL version CouchbaseBundle version
2.2.x 2.3.x
2.1.0 2.2.0
2.0.7 <= 2.1.1


Require simonsimcity/couchbase-bundle into your composer.json file:

    "require": {
        "simonsimcity/couchbase-bundle": "dev-master"

Register the bundle in your Kernel:

// app/AppKernel.php

public function registerBundles()
    $bundles = array(
        // ...
        new Simonsimcity\CouchbaseBundle\SimonsimcityCouchbaseBundle(),
        // ...

To configure the couchbase-cluster, you want to use in your application, please adjust the settings for the extension as needed. Here's a sample-configuration for two buckets (foo and bar) on a local cluster (the cluster available as a service called couchbase.cluster.main) by the service names couchbase.bucket.main_foo and, where the second bucket is secured by the password 123:

            username: root
            password: foo

                    name: foo
                    name: bar
                    password: 123

Using commands

You should see a couple of new methods in your symfony console:

  • couchbase:export-ddoc - to export design-documents, stored in your couchbase-cluster, to files
  • couchbase:import-ddoc - to import design-documents, saved as file, into your couchbase-bucket
  • couchbase:export-docs - to export couchbase documents, saved in your couchbase-bucket as files
  • couchbase:import-docs - to import couchbase documents, saved as file, into your couchbase-bucket

When importing documents from the filesystem to the database, it additionally checks if the folder, you defined, also contains a folder having the same name as your environment. If found, the documents in there are imported as well. If the name of the folder for design-documents contains the characters {connection}, they are replaced by the name of the selected couchbase-connection.

More to come ...


In order to use the command couchbase:import-docs, you first have to create a view called get_all_docs in a document called sf2_couchbase_bundle whose map-function looks just like this:

function (doc, meta) {
  emit(, null);

Example usage

app/console couchbase:export-ddoc foo

Will save all design-documents, found in the couchbase-definition foo, to the folder app/Resouces/foo/ in files having the file-extension .ddoc

app/console couchbase:import-ddoc -e test foo

Will import all files found in app/Resouces/foo/\*.ddoc and app/Resouces/foo/test/\*.ddoc. My recommendation is to create a file called sf2_couchbase_bundle.ddoc in the test folder so you'll always have that view available in your test environment.

app/console couchbase:export-docs foo data/

Will export all documents of your foo bucket to app/data/

app/console couchbase:import-docs foo data/

Will import all files, having the extension .json into your defined foo couchbase-bucket

Using the profiler for Couchbase

You can activate the stopwatch for every Couchbase-call by adding the following lines to your configuration:

    profiler_enabled: true

My personal recommendation is to add these lines to your config_dev.yml file.

Project Statistics

Sourcerank 5
Repository Size 32.2 KB
Stars 5
Forks 3
Watchers 2
Open issues 0
Dependencies 2
Contributors 4
Tags 9
Last updated
Last pushed

Top Contributors See all

Simon Schick Felix Schoeler norfil Sayed Hassan

Packages Referencing this Repo

Makes it easier to handle couchbases design-documents in symfony2
Latest release 2.3.2 - Updated - 5 stars

Recent Tags See all

2.3.2 March 13, 2017
2.3.1 March 13, 2017
2.3.0 January 09, 2017
2.2.0 January 09, 2017
2.1.1 January 08, 2017
2.1.0 April 29, 2016
2.0.0 November 27, 2015
1.0.0 November 27, 2015
1.0 November 27, 2015

Something wrong with this page? Make a suggestion

Last synced: 2017-03-13 19:13:40 UTC

Login to resync this repository