PHP 7 (PHPNG) Couchbase driver

Hi all-- we definitely are working on PHP 7. We appreciate your interest and understanding that doing this update isn’t as simple as we’d like it to be.

On the one hand, we are working on adding a number of features for the upcoming 4.5 release of Couchbase Server. You have probably seen a couple of posts about this. It has new features like Full Text Search and Sub-Document support.

On the other hand, we put some time and effort into PHP 7 shortly after it came out. Where the initial porting looked straightforward, there were more corner cases and unexpected problems that didn’t come out until runtime. Some of those changes make it most efficient to, unfortunately, maintain two different branches of the extension. Software porting can sometimes be like this when the platform changes under you. It’s very hard to estimate and while you really want to get it done, you have a lot to get done and can’t just stop everything for that new platform port.

Work has gone into PHP since I posted on Jan 11. Though I’ve not replied here in the last few weeks, it wasn’t because of lack of work from the team.

If you’d like to help push things along faster, there are a couple of things you can do. One is that you can jump into the branch and help with the porting/testing. It is, after all Open Source under an Apache 2.0 license. Second, is that if you’re an Enterprise subscriber, let your support/account team know so we can get information on the OS Platform and versions, timelines and further prioritize where we put our testing effort.

Hey Guys,

The php7 branch of our code-base will now compile and has been confirmed to correctly execute most operations. Please feel free to take a look, any help with testing is sincerely appreciated.

Cheers, Brett

1 Like

Note there was more work done in the last few days here. It’s not merged yet, but it’s up on our code review system. You can pull it from there if you’d like to let us know how it works out for you.

Hello,

I’ve cloned github repo and tested a simple get/set script, a part of our codebase that uses a counter() and the transcoders.php example.

transcoders.php worked perfectly.

The get/set was basically this:

$cb = new CouchbaseCluster('127.0.0.1:8091');
$bucket = $cb->openBucket('clients');
$r = $bucket->upsert('cb-test-1', 'test-1');
$rr = $bucket->get('cb-test-1');

var_dump($rr);

Here’s what I got:
2 Warnings on the line with upsert(), both were "Warning: Invalid callback , no array or string given in Unknown on line 0"
1 Warning on the line with get(), "Warning: Invalid callback , no array or string given in Unknown on line 0"
The upsert created an empty document with "att_reason": "invalid_json" in the meta.

I tried passing an object and array to to upsert, same result. The only thing that worked was a json string, which did not get decoded by get(), but did save correctly.

I also managed to get rid of the warnings by copying the transcoder related code from the transcoders example.

The counter() code did not work at all. The relevant code is $bucket->counter($resource, 1, ['initial' =>1]), it failed with an exception “The key does not exist on the server”, no document created.

The tests were run on an ubuntu 14.04 vagrant image with cb server version 4.5.0-1308 Enterprise Edition (build-1308).

I tried using the repo @ingenthr specified, but ./configure gives configure: WARNING: unrecognized options: --enable-couchbase and make fails.

Is the latest patchset 6 functional?
http://review.couchbase.org/#/c/62147/6

Looks like the FOREACH_OPCOOKIE_RES macro which was introduced into opcookie.h between patchset 3 and patchset 4 relies on C99, which (at least for me) is not being set as part of the configure / make process:

php-couchbase/opcookie.h:26:5: error: 'for' loop initial declarations are only allowed in C99 mode
     for (Type *Res = NULL; \
     ^
php-couchbase/bucket.c:125:9: note: in expansion of macro 'FOREACH_OPCOOKIE_RES'
         FOREACH_OPCOOKIE_RES(opcookie_get_res, res, cookie) {
         ^
php-couchbase/opcookie.h:26:5: note: use option -std=c99 or -std=gnu99 to compile your code
     for (Type *Res = NULL; \
     ^

Hey @gmot,

Patchset 6 is functional on Mac OS 10.11. I am working on getting my builders working for Windows/Ubuntu/CentOS at the moment. Once these are online, any minor fixes needed for cross-platform compat (such as c99 to c89 fixes) will be done. Sorry for the inconvenience. I hope to have this sorted later today.

Cheers, Brett

Hey @gmot,

Just trying to reproduce that issue you ran into. Any chance you could identify the exact platform you are on, as well as the PHP version you are using?

Cheers, Brett

Hi @brett19

This is Ubuntu 14.0.4, with PHP 7.0.5-2+deb.sury.org~trusty+1

Steps run:

This led to the error mentioned above.

After this, I fired up a clean Ubuntu 14.0 virtual machine, installed php5, cloned the php-couchbase repo, checked out the v2.1.0 tag, configured and built. This was a sanity check to make sure I could build the current GA release with the older php5, and this worked successfully.

Hi @brett19,

I pulled the new patch 8, and can confirm this does indeed build for me with php7.0 under Ubuntu 14.0.
I’ve done some basic gets/sets with Couchbase and at least that much is working well for me.

Thanks for looking into this, and I look forward to seeing it merged into master and published into an official release in the future.

Once you have a times cale for that in place, please do drop back to the forums and let us know, it would be appreciated.

On Archlinux PHP 7.0.5
With master from github and last commit id 48cd3264b0776129f49e72853cd1df532fbdd82f

I can’t compile :
/bin/sh /usr/local/src/php-couchbase/libtool --mode=compile cc -I. -I/usr/local/src/php-couchbase -DPHP_ATOM_INC -I/usr/local/src/php-couchbase/include -I/usr/local/src/php-couchbase/main -I/usr/local/src/php-couchbase -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php-couchbase/bucket.c -o bucket.lo
cc -I. -I/usr/local/src/php-couchbase -DPHP_ATOM_INC -I/usr/local/src/php-couchbase/include -I/usr/local/src/php-couchbase/main -I/usr/local/src/php-couchbase -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /usr/local/src/php-couchbase/bucket.c -fPIC -DPIC -o .libs/bucket.o
In file included from /usr/local/src/php-couchbase/bucket.c:5:0:
/usr/local/src/php-couchbase/paramparser.h: Dans la fonction ‘pcbc_pp_begin’:
/usr/local/src/php-couchbase/paramparser.h:37:52: attention : passing argument 2 of ‘_zend_get_parameters_array_ex’ from incompatible pointer type [-Wincompatible-pointer-types]
if (_zend_get_parameters_array_ex(param_count, args TSRMLS_CC) != SUCCESS) {
^
In file included from /usr/include/php/main/php.h:39:0,
from /usr/local/src/php-couchbase/couchbase.h:11,
from /usr/local/src/php-couchbase/bucket.c:1:
/usr/include/php/Zend/zend_API.h:250:14: note : expected ‘zval * {alias struct _zval_struct *}’ but argument is of type ‘zval *** {alias struct _zval_struct ***}’
ZEND_API int _zend_get_parameters_array_ex(int param_count, zval *argument_array);
^
In file included from /usr/local/src/php-couchbase/bucket.c:5:0:
/usr/local/src/php-couchbase/paramparser.h:115:43: attention : passing argument 2 of ‘zend_hash_find’ from incompatible pointer type [-Wincompatible-pointer-types]
if (zend_hash_find(htoptions, arg->name, strlen(arg->name)+1,

etc…

Hey,

I tried testing it again and everything I’ve tested worked.
My setup was similar to @gmot’s except I pulled a newer ref.

git clone https://github.com/couchbase/php-couchbase.git
git fetch http://review.couchbase.org/php-couchbase refs/heads/master
git checkout FETCH_HEAD
phpize7.0
./configure --with-couchbase --with-config=/usr/bin/php-config7.0
make
make install

The configure script had a warning configure: WARNING: unrecognized options: --with-config, but it worked.
I had to manually set up the ini file, I don’t know if the makefile was supposed to that for me or not.

These are the tests that I ran. Everything worked ok.
My PHP version was PHP 7.0.5-2+deb.sury.org~trusty+1 (cli) ( NTS ), running on a ubuntu VM.

I also ran our platform on it and everything seemed to work just fine.

I’d like to try it out on one of our test servers next week, if you consider the lib ready.

Finally !
Thank you !
sudo pecl install couchbase-2.2.0beta2

1 Like

Sorry Any Idea when this is going to be available for window platform?

I see that there is beta3 now and some people are actually using it. Is there ETA at this point? I feel like the new version is going to be released with 4.5 EE as 4.5 features are being added to the SDK.

We plan to release 2.2.0 as GA on 20th of June

1 Like

Hello,

Thank you for the ETA!

Are there any known issues with the latest beta version?

Hi @avsej,

Is this happening today?

2 Likes

Are there any known issues left? I saw it was not released at the 20th of June …

I have to shift release a bit. It will be ready by the end of this week

1 Like