Book Image

Couchbase Essentials

Book Image

Couchbase Essentials

Overview of this book

Table of Contents (15 chapters)
Couchbase Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Couchbase PHP SDK


The Couchbase PHP SDK is a PHP library that wraps the Couchbase C SDK. Before installing this library, the C library must be installed.

Current version

Currently, the latest version is 2.0.2. This SDK should be used for all development against Couchbase Server versions from 2.5 to 3.x.

How to obtain it

Linux users will be able to install the PHP SDK with pecl as follows:

$ pecl install couchbase

Additionally, the SDK team publishes Windows binaries, which may be found at http://docs.couchbase.com/developer/php-2.0/download-links.html. The source code for the library is available on GitHub at https://github.com/couchbase/php-ext-couchbase.

The basics

Here are a few snippets that demonstrate the basics of using the Couchbase PHP SDK:

//Configure the cluster
$cluster = new CouchbaseCluster('http://127.0.0.1:8091');

//Open a bucket connection
$bucket = $cluster->openBucket('default');

// Close the bucket connection
cluster.disconnect();