PHP Client 2.1 error

ldd /usr/lib/php5/20121212/couchbase.so
linux-vdso.so.1 => (0x00007fff86deb000)
libcouchbase.so.2 => /usr/lib/x86_64-linux-gnu/libcouchbase.so.2 (0x00007fb0e3914000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fb0e354f000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fb0e334a000)
libssl.so.1.0.0 => /lib/x86_64-linux-gnu/libssl.so.1.0.0 (0x00007fb0e30eb000)
libcrypto.so.1.0.0 => /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 (0x00007fb0e2d0f000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fb0e2b06000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fb0e2802000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fb0e24fc000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fb0e22e5000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fb0e20c7000)
/lib64/ld-linux-x86-64.so.2 (0x00007fb0e3de6000)

another check

~ $ strace php -i 2>&1  | grep couchbase
stat("/etc/php.d/99-couchbase.ini", {st_mode=S_IFREG|0644, st_size=43, ...}) = 0
open("/etc/php.d/99-couchbase.ini", O_RDONLY) = 3
open("/usr/lib64/php/modules/couchbase.so", O_RDONLY|O_CLOEXEC) = 3
open("/lib64/libcouchbase.so.2", O_RDONLY|O_CLOEXEC) = 3
/etc/php.d/99-couchbase.ini
write(1, "couchbase", 9couchbase)                = 9
write(1, "couchbase support", 17couchbase support)       = 17
write(1, "libcouchbase runtime version", 28libcouchbase runtime version) = 28
write(1, "libcouchbase headers version", 28libcouchbase headers version) = 28

what is your output?

strace php -i 2>&1 | grep couchbase
getcwd("/opt/php-couchbase", 4096) = 19
write(1, “/opt/php-couchbase”, 18/opt/php-couchbase) = 18
write(1, “/opt/php-couchbase”, 18/opt/php-couchbase) = 18

strange, it doesn’t even try to load the extension. What does this writes?

php -i | grep '\.ini'

maybe it just loads wrong ini files?

php -i | grep '.ini’
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
Additional .ini files parsed => /etc/php5/cli/conf.d/05-opcache.ini,
/etc/php5/cli/conf.d/10-pdo.ini,
/etc/php5/cli/conf.d/20-curl.ini,
/etc/php5/cli/conf.d/20-json.ini,
/etc/php5/cli/conf.d/20-readline.ini
user_ini.filename => .user.ini => .user.ini

siphash working steadily.

Okay, I’ve just installed ubuntu14.04 and agree on default installation it does not see it, but only if I don’t add it into /etc/php5/cli/php.ini. If I add it in default config to section [PHP] it starts complaining like this

# php --modules
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/couchbase.so' - /usr/lib/php5/20121212/couchbase.so: undefined symbol: php_json_decode_ex in Unknown on line 0

This does make sense because we depend on json.so, so then I just make sure that that json.so loaded before, our module:

extension = json.so
extension = couchbase.so

After that I get only warning about json.so being loaded second time (I guess somewhere after couchbase.so), and can see it in php -i:

# php -i | grep couchbase
PHP Warning:  Module 'json' already loaded in Unknown on line 0
couchbase
couchbase support => enabled
libcouchbase runtime version => 2.6.0 (git: 1bd30c6168cb7b5d4961910ead2a6bb84b5b30f3)
libcouchbase headers version => 2.6.0 (git: 1bd30c6168cb7b5d4961910ead2a6bb84b5b30f3)
PWD => /opt/php-couchbase
OLDPWD => /opt/php-couchbase
_SERVER["PWD"] => /opt/php-couchbase
_SERVER["OLDPWD"] => /opt/php-couchbase

I think that recommended way to add couchbase.so in separate file in directory /etc/php5/cli/conf.d/ and with prefix larger than default JSON module (on my installation it is /etc/php5/cli/conf.d/20-json.ini)

While the situation has not changed.
But I’m working on it.

php -i | grep couchbase
/etc/php5/cli/conf.d/30-couchbase.ini
couchbase
couchbase support => enabled
libcouchbase runtime version => 2.6.0 (git: 1bd30c6168cb7b5d4961910ead2a6bb84b5b30f3)
libcouchbase headers version => 2.6.0 (git: 1bd30c6168cb7b5d4961910ead2a6bb84b5b30f3)

What did you mean here?

I’m create /etc/php5/cli/conf.d/30-couchbase.ini with
extension = couchbase.so

May I assume that your issues has been solved?

In to /etc/php5/cli/conf.d/30-couchbase.ini
I’m wrote:
extension = couchbase.so

But I have error:

<b>Fatal error</b>: Class 'CouchbaseCluster' not found in <b>/var/www/html/...

For work I still use:
git checkout 7d3d89c11d40282afb85befd47bd4747f12181e6

How do you verify your installation?

I’ve just reinstalled new ubuntu14 box, followed your steps in first message, added extension in /etc/php5/cli/conf.d/30-couchbase.ini, and then run this script:

<?php
error_reporting(E_ALL);

$cluster = new CouchbaseCluster("couchbase://10.142.150.1");
$bucket = $cluster->openBucket('travel-sample');

$query = CouchbaseN1qlQuery::fromString("select count(*) from `travel-sample` where type = 'hotel'");
$res = $bucket->query($query);
var_dump($res);

Where 10.142.150.1 is my host machine with Couchbase Server 4.5 Beta with travel-sample bucket deployed. Do you have some small example which still reproduce the issue, but could be posted here?

  350  git clone https://github.com/couchbase/php-couchbase.git /opt/php-couchbase/
  351  cd /opt/php-couchbase
  352  phpize
  353  ./configure --with-couchbase 
  354  make
  355  make install
  356  service apache2 restart
  357  curl -i localhost/system/test/test.php?email=mne%40sergeykozlov.ru
  358  history

I have error:

<b>Fatal error</b>: Class 'CouchbaseCluster' not found in <b>/var/www/html/...

cat /etc/php5/cli/conf.d/30-couchbase.ini
extension = /usr/lib/php5/20121212/couchbase.so

I think this is an exceptional case.
Probably blame virtualization platform.
I use Proxmox with KVM machines.

php -i | grep couchbase
/etc/php5/cli/conf.d/30-couchbase.ini
couchbase
couchbase support => enabled
libcouchbase runtime version => 2.6.0 (git: 1bd30c6168cb7b5d4961910ead2a6bb84b5b30f3)
libcouchbase headers version => 2.6.0 (git: 1bd30c6168cb7b5d4961910ead2a6bb84b5b30f3)
PWD => /opt/php-couchbase
_SERVER[“PWD”] => /opt/php-couchbase

Could you modify y sample and run it in CLI mode? Does it work?

Sorry, what that means?:

When I do:

php --modules
[PHP Modules]
bcmath
bz2
calendar
Core
**couchbase**

However, the error is still present:

<b>Fatal error</b>: Class 'CouchbaseCluster' not found in <b>/var/www/html/nad/index.php</b> on line <b>318</b><br />

That meant to run script without apache server. For example store script as simple as this one into /tmp/test.php:

<?php
error_reporting(E_ALL);

$cluster = new CouchbaseCluster("couchbase://10.142.150.1");
$bucket = $cluster->openBucket('travel-sample');

$query = CouchbaseN1qlQuery::fromString("select count(*) from `travel-sample` where type = 'hotel'");
$res = $bucket->query($query);
var_dump($res);

And then run it in CLI mode (I used travel-sample bucket on Couchbase Server 4.5.0-beta):

$ php /tmp/test.php
array(1) {
  [0]=>
  object(stdClass)#5 (1) {
    ["$1"]=>
    int(917)
  }
}

Yes. You’re right.

In client mode, the script works properly.
Blame Apache.

@avsej
Here is a complete solution for my case:

For Apache2

pear config-set php_ini /etc/php5/apache2/php.ini
pecl config-set php_ini /etc/php5/apache2/php.ini
pecl install **couchbase-2.2.0beta2**
service apache2 restart

For a PHP cli:

nano /etc/php5/mods-available/30-couchbase.ini
write extension=couchbase.so
ln -s ../../mods-available/couchbase.ini /etc/php5/cli/conf.d/30-couchbase.ini

I have:

Ubuntu 14.04
Apache/2.4.7
PHP 5.5.9-1ubuntu4.16 (cli) (built: Apr 20 2016 14:31:27)
couchbase-2.2.0beta2