View Source

h2. Installing

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

libcouchbase: [http://www.couchbase.com/develop/c/current]

php-ext-couchbase: [http://www.couchbase.com/develop/php/current]

The Couchbase PHP Client Library is supported on PHP versions 5.3 and later. Couchbase does not support PHP 5.2 and earlier, although basic functionality may work OK for some users.

h2. Version Matrix

|| PHP Client \\ || Libcouchbase || Stable || Server Compatibility \\ || Supported Features \\ ||
| 1.1.x | 2.0.x | Yes | 2.0, 1.8 | * Key-Value operations
* MapReduce View Queries
* Lock, Touch |
| 1.0.x | 1.0.x | Maintenance | 2.0, 1.8 | * Key-Value operations |
| master branch | 2.0.x (or current \\
libcouchbase master) | Volatile | 2.0, 1.8 | Same as 1.1.x, maybe some \\
other goodies |
| 1.0.x branch | 1.0.x | Maintenance | 2.0, 1.8 | Same as 1.0.x release |


h2. Techniques

h3. 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.

{code}
$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;
}
{code}


h2. Installing From Source

It is a common need to install from source (there is a lot of variation in the Zend API revisions). The symptom is something like:

{code}
$ php -i > /dev/null
PHP Warning: PHP Startup: couchbase: Unable to initialize module
Module compiled with module API=20090626, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0
These options need to match
in Unknown on line 0
{code}

The first thing to do is install libcouchbase, the C client library for Couchbase, including development files. We recommend, where possible, installing binary packages of libcouchbase rather than building it from source. Use the above version matrix to determine the version you need.

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

{code}
$ git clone git://github.com/couchbase/php-ext-couchbase.git
$ cd php-ext-couchbase

$ phpize
$ ./configure
$ make
$ make install (or just copy modules/couchbase.so to your extension directory)
{code}

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/libcouchbase.so_ (or _libcouchbase.dylib, for OS X_) exists

h2. Testing

TBD

h2. Old Version 1.0.x

The 1.0.x PHP extension version is available in source form from the _1.0.x_ branch on github. This version is not recommended for current development, but is still available for existing applications which rely on it. Upgrading from 1.0.x to the current version requires very few, if any, code changes to the application.

h3. Binary packages

As outlined in the Version Matrix, the 1.0.x PHP extension needs the 1.x libcouchbase library. It will not work with libcouchbase 2.0.x. Binary packages for these older releases are available:

libcouchbase: [http://www.couchbase.com/develop/c/previous]

php-ext-couchbase: [http://www.couchbase.com/develop/php/previous]

h3. Building from source

After cloning the php-ext-couchbase repository from github, the 1.0.x branch can be checked out with:

$ git checkout 1.0.x

Follow the instructions for building from source as usual.