PHP SDK 2.0.0 Developer Preview
Over the past few months, the SDK development team has been working on defining a new interface for interacting with the SDKs, dubbed SDK 2.0 (not directly related to PHP SDK 2.0.0 which merely happens to implement a large portion of that specification). The existing SDKs were all designed around existing interfaces that were targeted towards the memcached project, and as such were very cache oriented and no longer effectively reflected the more document oriented nature of Couchbase Server 2.0. As such, we set out to define a new, more modern interface which would better model those traits.
Alongside this effort to revamp the overall SDK interface, the PHP SDK needed some love and attention, and so we got o work on revamping the PHP SDK itself. This ended up consisting of a complete rewrite from the ground up, and with this I am now happy to pass this on to developers to try hopefully receive some feedback.
Because of the ancient roots of the previous PHP SDK, there were unfortunately a great deal of intricacies with the behaviour of various functions, such as odd parameter ordering, inconsistent options between similar functions and duplication of behaviour. We now implement a uniform interface, here are a couple of quick examples of the new APIs.
Opening a bucket:
Insert a document:
Retrieving a document (not that the result of the operation is a Result object, with the document value stored in the value property):
Handling errors is also now consistent and reliable across all API calls.
We have also added full transcoder support, allowing you to provide custom serialization and deserialization strategies for any non-standard types you are using in your environment.
To see some examples of this, take a look at the transcoders example (https://github.com/couchbaselabs/php-couchbase/blob/master/examples/transcoders/index.php), or alternatively take a look at the Couchbase.class.php wrapper class (in the source root) where you will find the libraries default transcoders.
The documentation describing the full API is available to peruse here:
If you are on a linux system, to install the developer preview version of the library, simply grab the source code linked below, then build and install it:
If you are on a Windows system, you can opt to download the tarball and build the source yourself. Or alternatively there are links to the popular build types below as well.
|Windows PHP 5.3 NTS vc9 x86||php_couchbase-2.0.0dp1-5.3-nts-vc9-x86.zip|
|Windows PHP 5.3 ZTS vc9 x86||php_couchbase-2.0.0dp1-5.3-zts-vc9-x86.zip|
|Windows PHP 5.4 NTS vc9 x86||php_couchbase-2.0.0dp1-5.4-nts-vc9-x86.zip|
|Windows PHP 5.4 ZTS vc9 x86||php_couchbase-2.0.0dp1-5.4-zts-vc9-x86.zip|
|Windows PHP 5.5 NTS vc11 x64||php_couchbase-2.0.0dp1-5.5-nts-vc11-x64.zip|
|Windows PHP 5.5 ZTS vc11 x64||php_couchbase-2.0.0dp1-5.5-zts-vc11-x64.zip|
|Windows PHP 5.5 NTS vc11 x86||php_couchbase-2.0.0dp1-5.5-nts-vc11-x86.zip|
|Windows PHP 5.5 ZTS vc11 x86||php_couchbase-2.0.0dp1-5.5-zts-vc11-x86.zip|
NOTE: You MUST have libcouchbase installed prior to the installation of the php extension.
If you encounter any issues, please post directly to the Couchbase Communities site at http://www.couchbase.com/communities/php. Additionally, bugs can be reported directly through our issues tracker available here: https://www.couchbase.com/issues/browse/PCBC
I hope you enjoy!