PHP Fatal error: Class 'Couchbase' not found

I am trying to setup php to connect to couchbase and I get the following

PHP Fatal error: Class ‘Couchbase’ not found in /var/www/html/test-cbs-connection.php on line 3

Here is php source:

cat /var/www/html/test-cbs-connection.php

<?php // adjust these parameters to match your installation $cb = new Couchbase("127.0.0.1:8091", "", "", "default"); $cb->set("a", 101); var_dump($cb->get("a")); ?>

This is my server side configuration:

rpm -qa | grep libcouchbase

libcouchbase2-bin-2.4.0-0.0.dp1.x86_64
libcouchbase-devel-2.4.0-0.0.dp1.x86_64
libcouchbase2-core-2.4.0-0.0.dp1.x86_64
libcouchbase2-libevent-2.4.0-0.0.dp1.x86_64

cat /etc/php.d/couchbase.ini

; Enable couchbase extension module
extension = json.so
extension = couchbase.so

php -m|grep couchbase

couchbase

php /var/www/html/phpinfo.php |grep couchbase

Additional .ini files parsed => /etc/php.d/couchbase.ini,
couchbase

Thanks in advance for your assistance.

Which Webserver are you using?
Does the webserver user have read access to /etc/php.d/couchbase.ini?
I would replace php source with:

<?php phpinfo(); ?>

This will help you debug the problem as it will print out the modules and ini files that are being read.

I am using httpd-2.2.15-30.el6.centos.x86_64

ls -l /etc/php.d/couchbase.ini

-rw-r–r-- 1 root root 81 Jul 15 01:01 /etc/php.d/couchbase.ini

php /var/www/html/phpinfo.php | grep couch

Additional .ini files parsed => /etc/php.d/couchbase.ini,
couchbase

cat /etc/php.d/couchbase.ini

; Enable couchbase extension module
extension = json.so
extension = couchbase.so

Hey Ryan,

Looks like you may be using the 2.x edition of our SDK which has changed the interfaces significantly. Take a look at our new documentation site (http://docs.couchbase.com/developer/php-2.0/php-intro.html) for more information!

Cheers, Brett

I’ve installed couchbase on centos 7 server:

Build process completed successfully
Installing '/usr/local/lib/php/extensions/no-debug-non-zts-20131226/couchbase.so’
install ok: channel://pecl.php.net/couchbase-1.2.2
configuration option “php_ini” is not set to php.ini location
You should add “extension=couchbase.so” to php.ini

Although I’ve uploaded file to test this on domain over this server:

www.elambak.com/cb.php

It throwing the same error class not found.

I guess there’s any compatibility issue or may I need to upload “cb.php” (test file) at parent location as IP but this I can’t. Is this may cause the issue as I am trying to access couchbase class from domain location.

Or its not an issue at all I should access couchbase class from any place.