2.x PHP Client Library for Couchbase
C PHP Other
Pull request Compare This branch is 186 commits ahead, 5 commits behind brett19:master.
Latest commit a00733d Feb 16, 2018
remicollet and avsej Improve install documentation (link to fedora official package)
fixes #21

Change-Id: I90d2f13a0a6595a2e29726659359962af39e1839
Reviewed-on: http://review.couchbase.org/89562
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Permalink
Failed to load latest commit information.
api PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
contrib PCBC-443: Remove embedded PHP code Mar 2, 2017
examples PCBC-497: Add health check functions Jan 2, 2018
fastlz PCBC-366: Correct issue with legacy transcoder compression. Nov 4, 2015
integration PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
src/couchbase PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
tests PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
.clang-format Use pool with persistent connections Mar 7, 2017
.gitignore PCBC-524: fix memory leak when using authenticateAs() Jan 2, 2018
LICENSE Initial Commit Apr 24, 2014
README.md Improve install documentation (link to fedora official package) Feb 16, 2018
config.m4 PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
config.w32 PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
couchbase.c PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
couchbase.h PCBC-508: Add support for FTS advanced sorting Feb 12, 2018
datainfo.h PCBC-443: Remove embedded PHP code Mar 2, 2017
exception.c PCBC-485: Expose enhanced error attributes ("context" and "ref") Sep 4, 2017
log.c PCBC-443: Remove embedded PHP code Mar 2, 2017
log.h PCBC-443: Remove embedded PHP code Mar 2, 2017
opcookie.c Reformat all files with clang-format Mar 8, 2017
package.xml Release 2.4.4 Feb 12, 2018
paramparser.c Reformat all files with clang-format Mar 8, 2017
php_couchbase.h Release 2.4.4 Feb 12, 2018
transcoding.c PCBC-449: update API documentation Mar 6, 2017

README.md

Couchbase PHP Client Build Status

This library allows you to connect to a Couchbase cluster from PHP. It is a native PHP extension and uses the very fast libcouchbase library to handle communicating to the cluster over the Couchbase binary protocol. It supports 5.x and 7.x releases of PHP interpreter.

Useful Links

Installing

The target system should have libcouchbase installed. Detailed guide and links to the most recent versions located here: https://developer.couchbase.com/server/other-products/release-notes-archives/c-sdk.

PECL

Couchbase PHP client generally available through PECL: http://pecl.php.net/package/couchbase

pecl install couchbase

Binary packages

RPM package for Fedora available in official repository, its name is php-pecl-couchbase2.

dnf install php-pecl-couchbase2

RPM package for RHEL and CentOS linux available on Remi's repository.

yum install php-pecl-couchbase2

Additionally Windows builds available from Release Notes and Archives page.

On MacOS platform, the library could be installed via Homebrew:

brew tap homebrew/homebrew-php
brew install php70-couchbase # or other version instead of 70 (PHP 7.0)

Build from sources

If you are going to prepare patches, or just need to install the most recent version from git, make sure you have PHP development tools and headers installed, and run the following commands:

git clone git://github.com/couchbase/php-couchbase.git
cd php-couchbase
phpize
./configure --with-couchbase
make && make install

Introduction

Connecting to a Couchbase bucket is as simple as creating a new Connection instance. Once you are connect, you may execute any of Couchbases' numerous operations against this connection.

Here is a simple example of instantiating a connection, setting a new document into the bucket and then retrieving its contents:

$cluster = new \Couchbase\Cluster('localhost');
$db = $cluster->openBucket('default');
$db->upsert('testdoc', array('name'=>'Frank'));
$res = $db->get('testdoc');
var_dump($res->value);
// array(1) {
//   ["name"]=>
//   string(5) "Frank"
// }

Documentation

An extensive documentation is available on the Couchbase website. Visit our PHP Community on the Couchbase website for the documentation as well as numerous examples and samples.

To build PHP API reference, phpDocumentor have to be installed

pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor

That will bring phpdoc command into PATH. The following steps assume that current directory is the root of this repository:

ver=$(git describe | sed 's/^v//')
rm -rf couchbase-php-client-$ver
phpdoc --target couchbase-php-client-$ver --directory api

After that all reference documentation will be stored in couchbase-php-client-2.3.0, if current tag is 2.3.0.

Source Control

The source code is available at https://github.com/couchbase/php-couchbase.

To execute our test suite, simply install and execute phpunit against your checked out source code. Tests assume that you have Couchbase Server with default bucket running on localhost (otherwise use environment variable CB_DSN, CB_ADMIN_USER, CB_ADMIN_PASSWORD, CB_BUCKET, CB_USER, CB_PASSWORD. E.g. CB_DSN=couchbase://192.168.1.42/ CB_BUCKET=travel-sample).

curl -L https://phar.phpunit.de/phpunit.phar > ~/bin/phpunit
chmod a+x ~/bin/phpunit
# or just 'dnf install php-phpunit-PHPUnit' on Fedora 24+

phpunit tests/

Integration tests require some prerequisites, so once they met, you can run integration tests with:

phpunit integration/

It is also possible to run tests using CouchbaseMock:

CB_MOCK=1 phpunit tests/

Server version guard might be specified by CB_VERSION (default is 4.6). The tests which depend on functionality, which is not supported by CB_VERSION, will be skipped automatically.

License

Copyright 2016-2017 Couchbase Inc.

Licensed under the Apache License, Version 2.0.

See LICENSE for further details.