Couchbase PHP 1.1 Preview: Views
Note: The releases tagged with -dp are Developer Previews. We are excited to share our technology as early as possible with you, but at this point, we do not recommend running Developer Previews in production. Expect things to break and change in the future. That said, for the PHP SDK, we are currently only adding View functionality for Couchbase Server 2.0, and that is subject to change, everything that is in the 1.0.x release line is considered stable.
Download and Installation
See the right sidebar for your download options. Note that a prerequisite for installation of this client library is the C client library.
After download, unpack the archive:
The resulting directory includes a file called couchbase.so that is the PHP extension for your system.
Edit your php.ini to include this line:
To find where your php.ini file is, try php -i | grep couchbase or look at your <?php phpinfo() ?> output.
First Run
Create this PHP script. It gets you started in three little steps:
// adjust these parameters to match your installation
$cb = new Couchbase("127.0.0.1:8091", "user", "pass", "default");
$cb->set("a", 1);
var_dump($cb->get("a"));
?>
The line with new Couchbase() establishes a connection to our Couchbase Server installation and gives us access to the Couchbase Server API. Next, we set the value of the key "a" to 1. Finally, we get the value for our key "a" and print it out. When you run this script, it should print int(1).
View Support
$cb = new Couchbase("127.0.0.1:8091", "user", "pass", "default");
$result = $cb->view("design_doc", "view_name");
foreach($result["rows"] as $row) {
echo $row->key;
}
$cb = new Couchbase("127.0.0.1:8091", "user", "pass", "default");
$result = $cb->view("_all_docs", "");
foreach($result["rows"] as $row) {
echo $row->key;
}
For more information, please see the Getting Started Guide.
Support
If you have any questions, problems or suggestions, please let us know on the Couchbase SDK forums.
