PHP Client 2.1 error

Hello.
@avsej
@brett19

I have:
Ubuntu 14.04
PHP 5.5.9

I try to install the client:

wget -O/etc/apt/sources.list.d/couchbase.list http://packages.couchbase.com/ubuntu/couchbase-ubuntu1404.list

wget -O- http://packages.couchbase.com/ubuntu/couchbase.key | apt-key add -

apt-get update

apt-get install libcouchbase2-libevent libcouchbase-dev

git clone https://github.com/couchbase/php-couchbase.git /opt/php-couchbase/

cd /opt/php-couchbase

phpize

./configure --with-couchbase

make && make install

But the PHP does not see the client.

If I do so, the client sees the PHP:

pear config-set php_ini /etc/php5/apache2/php.ini
pecl config-set php_ini /etc/php5/apache2/php.ini
pecl install couchbase

Then I execute the code and get the error:

    $cluster = new CouchbaseCluster("http://192.168.0.181:8091", "Administrator", "Pass", "default");
 $bucket = $cluster->openBucket("test");

    $query = CouchbaseViewQuery::from("user", "spring");
    try {
        $res = $bucket->query($query);
        print_r($res);
    } catch (Exception $e) {
        echo "Error";
    }

Error:
Fatal error: Cannot use object of type stdClass as array in [CouchbaseNative]/CouchbaseBucket.class.php on line 284

What am I doing wrong?
Thanks!

What is the value of this parameter here?

And while you are building from git sources, could you specify SHA1 of the commit you are using?

$_REQUEST[‘spring’] can be discarded.

SHA1 of the commit: 52c89dcbe061414ee3f35380da7c29715dfb8bd4

Hi Kozlov,

This is known issue from PHP SDK as far as I understand. I cannot believe this hasn’t fixed yet.

See Cannot install SDK v2.1.0 on Mac OSX

$bucket->query($query, null, true) should be a fix for your problem.

If CB team is not willing to fix this after 5 months+, I think this bug should be noted somewhere.

Thank you very much.
It really helped.

If I use.
git checkout 7d3d89c11d40282afb85befd47bd4747f12181e6
That everything is working properly.
And if.
commit: 52c89dcbe061414ee3f35380da7c29715dfb8bd4
That get the error.
Fatal error: Cannot use object of type stdClass as array in [CouchbaseNative]/CouchbaseBucket.class.php on line 284

The bug has been fixed even earlier in this patch https://github.com/couchbase/php-couchbase/commit/678bb679de2f8f3b360be7b29a3ca2925da1966f

@Kozlov could you make sure you do not have any modified/old files when you are compiling master branch? Because it is not reproducing, but it reproduces when I do the following steps:

git checkout 52c89dcbe061414ee3f35380da7c29715dfb8bd4
git clean -dfx
git revert 678bb679de2f8f3b360be7b29a3ca2925da1966f
phpize
./configure --with-couchbase 
make
sudo make install

@moon0326 the fix has been done almost 7 months ago

If I act in this way.

git checkout 52c89dcbe061414ee3f35380da7c29715dfb8bd4
git clean -dfx
git revert 678bb679de2f8f3b360be7b29a3ca2925da1966f
phpize
./configure --with-couchbase 
make
sudo make install

That PHP does not see the Client Library.

I have:
Ubuntu 14.04
PHP 5.5.9

I get connected client is the only way:

pear config-set php_ini /etc/php5/apache2/php.ini
pecl config-set php_ini /etc/php5/apache2/php.ini
pecl install couchbase

When I use the pecl I get the latest version Client Library?

The bug is fixed in the code, but never released in v.2.1.x versions and 2.2 is still in beta.

v2.1.0 was released on Nov 4, 2015. The fix was committed on Nov 9. When a stable version is not released, it is not fixed for the customers as far as I concern.

I mean I’m able to reproduce your issue only when I revert the fix 678bb679de2f8f3b360be7b29a3ca2925da1966f, if you run pecl install couchbase-2.2.0beta3 you will get the most recent extension. But make sure you don’t have any other extensions installed.

Yes, you are correct, but Sergey has used version from git and I meant that it have to be fixed in his code base, and because he mentioned issues with discovering shared object I guessed that probably either something messed with working directory where extension has been built, or there are multiple extensions on the system.

He gets error when he installs couchbase sdk through pecl, which is using 2.1.0 by default.

If I do so, the client sees the PHP:

pear config-set php_ini /etc/php5/apache2/php.ini
pecl config-set php_ini /etc/php5/apache2/php.ini
pecl install couchbase
Then I execute the code and get the error:

$cluster = new CouchbaseCluster("http://192.168.0.181:8091", "Administrator", "Pass", "default");

$bucket = $cluster->openBucket(“test”);

$query = CouchbaseViewQuery::from("user", "spring");
try {
    $res = $bucket->query($query);
    print_r($res);
} catch (Exception $e) {
    echo "Error";
}

Error:
Fatal error: Cannot use object of type stdClass as array in [CouchbaseNative]/CouchbaseBucket.class.php on line 284

What am I doing wrong?

Four days I am trying to understand this problem.
And every time I use the new server (Ubuntu 14.04) virginity.

Shortly before I used the Couchbase 3. And the Client Library regularly worked over the years.

This is correct in terms that it still failing.

@Kozlov could you post output of make install and php -i | grep extension_dir, please?

Ok.

make install
Installing shared extensions:     /usr/lib/php5/20121212/

and

php -i | grep extension_dir
extension_dir => /usr/lib/php5/20121212 => /usr/lib/php5/20121212

Here is the beginning of my problem:

solve:
git checkout 7d3d89c11d40282afb85befd47bd4747f12181e6

Here are the details:

ls -lh /usr/lib/php5/20121212
total 732K
-rwxr-xr-x 1 root root 650K May 27 22:23 couchbase.so
-rw-r--r-- 1 root root  88K Apr 20 15:50 curl.so
-rw-r--r-- 1 root root  67K Feb 18  2014 json.so
-rw-r--r-- 1 root root 136K Apr 20 15:50 opcache.so
-rw-r--r-- 1 root root 112K Apr 20 15:50 pdo.so
-rw-r--r-- 1 root root  31K Apr 20 15:50 readline.so
-rwxr-xr-x 1 root root  36K May 20 09:14 siphash.so

siphash working steadily.

it`s true file size?

What does say ldd /usr/lib/php5/20121212/couchbase.so, does it use absolute path in php.ini, and does it show any warning, when you say “Does not see extension”?

Yes, it is. On my system (64 bit) it is 687240 bytes

I’m use

extension = couchbase.so
extension = siphash.so

in to /etc/php5/cli/php.ini

And get only siphash.