Class 'Couchbase' not found
I've successfully setup Couchbase Server 1.8 on Ubuntu Linux 11.10 64bit. I've also added the PHP SDK and have added the following line to php.ini and restarted Apache
extension=/opt/couchbase/php-ext-couchbase/couchbase.so
I then installed the C Client Library
Once that was finished, I created the test PHP file as such:
<?php
$cb = new Couchbase("127.0.0.1:8091", "username", "password", "default");
$cb->set("a", 1);
var_dump($cb->get("a"));
?>
The username and password are updated in the actual script, and only the default bucket exists. When I run the PHP script from the command line I receive the following error:
PHP Fatal error: Class 'Couchbase' not found in /var/www/couchbase.php on line 2
This same error is produced whether I include the couchbase.so extension in php.ini or not. Not sure why this is happening and any help would be much appreciated
I've managed to figure this one out and it had to do with PHP being picky about how the extension was loaded. After running "php -m" from the command line, I could see that the Couchbase extension wasn't being loaded...so here's what I did.
I opened up a phpinfo page to find PHP's default extension dir, and copied the couchbase.so file there.
Once that was done, I removed the "extension=/opt/couchbase/php-ext-couchbase/couchbase.so" file form php.ini
I then created a new couchbase.ini file in /etc/php5/conf.d and added the line "extension=couchbase.so"
Because the couchbase.so file was copied into PHP's default extension dir, a path wasn't required.
I restarted Apache, ran "php -m" and the extension showed as being loaded. I then ran the Couchbase PHP test script and received the following output:
int(1)
Success!