PHP message: PHP Fatal error: Class 'CouchbaseCluster' not found

hi,
I am getting

nginx error : AH01071: Got error 'PHP message: PHP Fatal error: Class ‘CouchbaseCluster’ not found in [appName.module]

I have already installed PHP SDK and added extension =couchbase.so in php.ini
but still, I am getting this error.
I have checked the phpinfo() file but couchbase is not showing in that
I am using couchbase Enterprise Edition 5.0.1 build 5003 and the latest PHP SDK.

Installed packages, channel pecl.php.net:
=========================================
Package   Version State
couchbase 2.6.0   stable
pcs       1.3.3   beta

server: apache2

what should I do to fix this?

Thanks in advance

In your phpinfo() you should be able to see the path to config is beeing used. You might be using incorrect php.ini when adding couchbase extension (also I noticed nginx error in your logs, but you said you are using apache2).
Something like this.

Hi avsej,

here is my PHP info file

I have added the extension in the php.ini in the above-said php.ini file

[PHP]
extension=couchbase.so
extension=json.so
;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;

"/opt/plesk/php/5.6/etc/php.ini

Hi avsej,

it appears that php is not able to load dynamic library

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/pcs.so' - 
/usr/lib/php/20131226/pcs.so: cannot open shared object file: No such file or directory in Unknown on line 
0
PHP Warning:  Module 'json' already loaded in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/couchbase.so' - 
/usr/lib/php/20131226/couchbase.so: cannot open shared object file: No such file or directory in Unknown 
on line 0

any idea how to fix this?

You can safely remove pcs.so from the list of extensions, as couchbase does not depend on it anymore.

1 Like

Hi avsej,

I have removed pcs.so from the list of extension and I still have the error for couchbase.so
PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/couchbase.so' - /usr/lib/php/20131226/couchbase.so: cannot open shared object file: No such file or directory in Unknown on line 0

But you do have this file at /usr/lib/php/20131226/couchbase.so?

Also make sure you have loaded json.so extension before couchbase.so (it is described in our docs).

Hi avsej,

I have checked at /usr/lib/php/20131226/couchbase.so and I don’t have couchbase. so at that location.
and I have reloaded json.so before couchbase.so

How did you install couchbase extension? If you’ve used pecl install, then make sure pecl was using correct PHP interpreter. If you installed it from tarball, then make sure that you use phpize from PHP interpreter you use with apache2

I have used pecl to install couchbase PHP SDK.
How do I specify correct PHP interpeter while installing PHP SDK?

Thanks in advance

In general pecl -V shows the info about current PHP interpreter version:

$ pecl -V
PEAR Version: 1.10.7
PHP Version: 7.2.15
Zend Engine Version: 3.2.0

$ pecl config-show | grep ext_dir
PHP extension directory        ext_dir          /usr/lib64/php/modules

If this does not give you version you are using, then probably you have multiple PHP interpreters installed and couchbase.so got installed somewhere else when you execute sudo pecl install couchbase

On my system /usr/bin/pecl is just a shell script, which runs system PHP interpreter with peclcmd.php as argument:

$ cat /usr/bin/pecl
#!/usr/bin/sh
exec /usr/bin/php -C \
    -d include_path=/usr/share/pear \
    -d date.timezone=UTC \
    -d output_buffering=1 \
    -d variables_order=EGPCS \
    -d safe_mode=0 \
    -d register_argc_argv="On" \
    /usr/share/pear/peclcmd.php "$@"

So if I have PHP installed into some other path and want to use the same pecl command, I could patch it like this

$ sed 's:/usr/bin/php:/tmp/prefix/bin/php:' /usr/bin/pecl > /tmp/prefix/bin/pecl
$ chmod a+x /tmp/prefix/bin/pecl

$ /tmp/prefix/bin/pecl -V
PEAR Version: 1.10.7
PHP Version: 7.0.9
Zend Engine Version: 3.0.0

$ /tmp/prefix/bin/pecl config-show | grep ext_dir
PHP extension directory        ext_dir          /tmp/prefix/lib/php/extensions/no-debug-non-zts-20151012

Hi avej,

I have noticed an issue that might be the causing the PHP SDK not found error

The problem is the output of php --ini and phpinfo() is totally different maybe that is causing the issue,.

php --ini output is as follows.

root@techpatrol:/# php --ini
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/couchbase.so' - 
/usr/lib/php/20131226/couchbase.so: cannot open shared object file: No such file or directory in Unknown on line 0
Configuration File (php.ini) Path: /etc/php/5.6/cli
Loaded Configuration File:         /etc/php/5.6/cli/php.ini
Scan for additional .ini files in: /etc/php/5.6/cli/conf.d
Additional .ini files parsed:      /etc/php/5.6/cli/conf.d/10-mysqlnd.ini,.

the loaded configuration files are different.
I wanted the PHP SDK to be installed for /opt/plesk/php/5.6 but instead, it got installed for /etc/php/5.6.

What are your thoughts about this?

also the output of the pecl install couchbase says that it installed couchbase.so in
mv /tmp/pear/temp/pear-build-rootaxotS5/install-couchbase-2.6.0//usr/lib/php/20170718/couchbase.so /usr/lib/php/20170718/couchbase.so

but the php is trying to load the couchbase.so in
PHP Startup: Unable to load dynamic library '/usr/lib/php/20131226/couchbase.so'

Thanks in advance

Yes, this definitely matters.
The rule of thumb would be either leave only one interpreter on the system and use it everywhere (both CLI and httpd) or always check which interpreter and which config you are using in every single case.

Also, did you know that PHP 5.6 has reached its end of life in last year? It is not supported at all: https://secure.php.net/supported-versions.php. We will drop 5.x support in next release of PHP SDK, so look at https://secure.php.net/eol.php for migration guides.