Couchbase PHP Client Library

Skip to end of metadata
Go to start of metadata
You are viewing an old version of this page. View the current version. Compare with Current  |   View Page History


Ideally it is recommended you install everything from the binary releases featured at


_libcouchbase: _


Developer Preview



PHP Version
Libcouchbase Version Stable Server Compatibility
Supported Features
1.0.x 1.0.x Yes 2.0, 1.8
  • Key-Value operations
1.1-dp5 2.0.0beta2 Developer
2.0, 1.8
  • Key-Value operations
  • MapReduce View Queries
  • Lock, Touch
master branch 2.0.0beta2 (or current
libcouchbase master)
Volatile 2.0, 1.8 Same as 1.1-dp5, maybe some
other goodies
1.0.x branch 1.0.x Yes (mostly) 2.0, 1.8 Same as 1.0.x release

Installing From Source

It is a common need to install for source (specifically, there is a lot of variation in the Zend API revisions)

Recommended: *The first thing to do is install libcouchbase. If you are using a 1.8 server version OR are using a server of any version, but are not planning to employ views and MapReduce, you may use the *stable version of libcouchbase (this is versioned as 1.0.x).

NOTE: The stable php extension version is available in source form from the 1.0.x branch on github.

If you wish to use the new and shiny features of Couchbase Server 2.0[-beta], then you need to use the Developer Preview (DP) versions of both libcouchbase and the php extension

It is not required to build both libcouchbase and the php extension from source. As long as you have any version of libcouchbase installed (and its development headers, i.e. libcouchbase-dev or libcouchbase-devel) it is possible to compile and build the PHP extension

Use the above version matrix to determine the version you need.

For php-ext-couchbase source installation, do the folllowing:

$ git clone git://
$ cd php-ext-couchbase

# If wishing to compile the stable branch of php-ext-couchbase, do the following
$ git checkout 1.0.x

$ phpize
$ ./configure
$ make
$ make install (or just copy modules/ to your extension directory)

If libcouchbase is installed in a non-default path (for example, in your home directory) then you need to specify --with-couchbase=$dir to ./configure, where $dir is the installation prefix; such that $dir/include/libcouchbase/couchbase.h exists, and that $dir/lib/ (or libcouchbase.dylib, for OS X) exists




Connecting to a Live Server

The 1.0.x PHP Couchbase Client Library does not currently use multiple URIs, but this can be easily worked around when setting up the connection. A future release will add support for multiple URIs.

$servers = array("http://server1:8091", "http://server2:8091");

function my_couchbase_connect($servers) {
  do {
    if(empty($servers)) {
      echo "no suitable server found";
      return false;
      // throw
    $server = array_pop($servers);
    $cb = couchbase_connect($server);
  } while(!$cb);

  return $cb;
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.