Class '_CouchbaseBucket' not found


#1

Hi, getting my feet wet I stumble hard immediately:

    function _test_couchbase() {
        include '/scripts/php-couchbase/stub/connstr.php';  
        include '/scripts/php-couchbase/stub/CouchbaseBucket.class.php';  
        include '/scripts/php-couchbase/stub/CouchbaseCluster.class.php';  
        $myCluster = new CouchbaseCluster('couchbase://localhost');
        $myBucket = $myCluster->openBucket('default');
        # Class '_CouchbaseBucket' not found 
    } # _test_couchbase

The exact error message is

Class '_CouchbaseBucket' not found in ...\php-couchbase\stub\CouchbaseBucket.class.php on line 74

Windows 7 64 bit, php_couchbase.dll with date 2015-01-21 from php_couchbase-2.0.3-5.5-zts-vc11-x64.zip, PHP Version 5.5.20

Did I miss something? What can I do?


#2

I guess you dont need to include stub classes… Only we need php_couchbase.dll . Then everything runs fine in windows


#3

Thank you for your hint.

If I omit all these includes, I simply get

Fatal error: Class ‘CouchbaseCluster’ not found in …php on line 639

Adding ‘‘include ‘/scripts/php-couchbase/stub/CouchbaseCluster.class.php’;’’ I get

Fatal error: Call to undefined function cbdsn_parse() in …\scripts\php-couchbase\stub\CouchbaseCluster.class.php on line 43

Adding ‘‘include ‘/scripts/php-couchbase/stub/connstr.php’;’’ I get

Fatal error: Class ‘CouchbaseBucket’ not found in …\scripts\php-couchbase\stub\CouchbaseCluster.class.php on line 61

Adding ‘‘include ‘/scripts/php-couchbase/stub/CouchbaseBucket.class.php’;’’ I get

Fatal error: Class ‘_CouchbaseBucket’ not found in …\scripts\php-couchbase\stub\CouchbaseBucket.class.php on line 74

which is the error message I started this thread with.

So obviously this is not the way to operate with php_couchbase.dll, but with CouchbaseCluster instead.

How would you work with php_couchbase.dll alone? Could you give me a sample script?


#4

Hey i have put up configuration steps and sample code here for you.

https://github.com/keshavkatwe/couchbase.

Check this. Let me know if this solved your problem.


#5

Absolutely great, thanks a lot!

But, unfortunately, it does not work on my machine, as already stated.

Step 1: First make sure you have install xampp with php 5.5 version in windows.Because 5.6 is not supported by couchbase.

Been there, done that. I first tried to set up couchbase with PHP 5.6 and found out that 5.5 is the latest supported version, so I stepped back as reported.

Step 2: Copy php_couchbase.dll to C:\xampp\php\ext. And copy file libcouchbase.dll to C:\xampp\php and C:\xampp\apache\bin.

Made sure that everything was okay. So this shouldn’t be a problem.

Step 3: Restart xampp. And it is good to go.

Well, this amounts to restarting the Apache server, easy enough to check that this doesn’t change anything. Alas, the result is as reported. Now what happens here?

I didn’t mention that I also registered Couchbase Sync Gateway as a Windows service which answers as follows:

127.0.0.1:4984/
{
  "couchdb": "Welcome",
  "vendor": {
    "name": "Couchbase Sync Gateway",
    "version": 1
  },
  "version": "Couchbase Sync Gateway/1.0.3(81;fa9a6e7)"
}

127.0.0.1:4985/
{
  "ADMIN": true,
  "couchdb": "Welcome",
  "vendor": {
    "name": "Couchbase Sync Gateway",
    "version": 1
  },
  "version": "Couchbase Sync Gateway/1.0.3(81;fa9a6e7)"
}

I don’t know anything about the couchbase system; last year I learned about CouchDB but wasn’t ready to use it. Now I think about improving my memcached system (which works as it should) in order to prepare for a scale-up.

I noticed my Process Explorer all of a sudden reports 50% CPU usage. Turns out that memcached.exe is using about 40%, sigar_port.exe another 10%. What’s that?

Google tells me that this is part of the couchbase system. Restarting that memcached.exe via Process Explorer does not change anything. Restarting my memcached server via services.msc does not change anything, so this seems to be another process. Restarting my couchbase server does not help.

Yesterday, I installed another service: C:\xampp\Couchbase\Server\erts-5.10.4\bin\erlsrv.exe. Restarting that one takes time… in the meantime CPU usage is at 100%… erl.exe taking 20% as well. Time to reboot.

Also, we just had a lightning outside and thunder, so I better quit for a while.

Afterwards, the same thing. Now what’s happening here? memcached.exe 83%…91%… all services shut down. Kill memcached.exe from Process Explorer does not work. Close FireFox. Nothing changes. No sigar_port.exe, though.

Again, warm reboot. Watched CPU load. Things are normal. Activated Firefox, memcached runs wild.

Google?

https://issues.couchbase.com/browse/MB-12775
memcached.exe stays at 60-80% CPU, erl.exe stays at ~10% while no activity on database

neatcode added a comment - 29/Nov/14 11:27 PM
OK, I uninstalled Couchbase Server, then reinstalled it (enterprise_3.0.1-windows_amd64.exe). I then reinstalled n1ql developer preview 3. After some setup, the script seems to be running fine and not causing the memcached.exe to spin out.

Mine is enterprise_3.0.2-windows_amd64.exe. The next guys uses Linux:

chmod777 added a comment - 10/Dec/14 4:24 AM
Hello Guys,

I carefully read the thread and we may have the exact same issue on our couchbase 3.0.0.
Memcached worked fine since 2 months until yesterday (when my cbtransfer command reach 47%).
It now takes 90% of CPU (there is no activity, no get/set request), I did a collect_information, where can I upoad it (70mo) ?

I stopped couchbase (service couchbase-server stop), memcached has to be kill manually as it doesn’t respond to couchbase kill signal.
On restart (service couchbase-server start), memcached re-takes 87% of CPU …
I did stop/start 3 times, always the same issue, memcached take all the CPU.

Okay, I took this advice and removed this program (Couchbase-Server running on localhost:8091) solving my problem with high load immediately.

To make sure, that this program didn’t interfere with what we were investigating, I repeated the test with same result, unfortunately.

Any idea? Am I on the right track to begin with?

My idea was that Couchbase Sync Gateway would set up several instances of database servers much like Riak would do, and I could communicate with this cluster via php_couchbase.dll.

The command
$clusterConnection = new CouchbaseCluster(‘couchbase://localhost’);
looks very much like what I would like to do, doesn’t it? Furthermore, it suggests that I do have a cluster, and the above (Couchbase Sync Gateway) does look like a cluster to me.


#6

Having read some more, I realize I must of been on the wrong track. Couchbase Sync Gateway should not be my first concern, but rather Couchbase-Server. Anyway, having had installed this one also, I still don’t understand why my code didn’t work.


#7

Hey kklepper,

Have you verified that the Couchbase extension appears in your phpinfo() output? The stubs are built into the extension, so you should never need to manually include them, if the classes appear to be missing, it would seem the extension is not loading. Don’t forget you need to add the extension=php_couchbase.dll line to your php.ini, and ensure you have downloaded the correct extension build for your particular environment (match the version, zts/nts and compilers between your PHP build and the extension build).

Cheers, Brett


#8

Thanks a lot brett19, I think this is it – phphinfo does not show the couchbase extension. I’ll dig into that and will report later.


#9

I’m sorry, this will be a long rant, but you may learn that things are not as easy as experts expect.

Of course, I included the extension php_couchbase.dll in my php.ini via boilerplate.

[couchbase]

; Load the required extension (please note that this path needs to be
; absolute if the module isn’t installed in the default search path
; for extensions (specified as extension_dir)).
;extension=couchbase.so
extension=php_couchbase.dll
; and some more

Actually I had to experiment a lot until I finally found the right (?) version – Apache simply wouldn’t start as a service otherwise, as far as I remember. Starting Apache from the shell would show the mismatch of versions quite clearly – that was when I worked with PHP version 5.6. So this way I learned that Couchbase would not run on 5.6, whence I stepped back to PHP 5.5.20, resolving this issue.

So reasoning backwards I would argue that as we don’t have any complaints anymore, by chance I hit the right version, okay?

Obviously this is not so, or something else is wrong.


Checking again, httpd does start from the shell (after having killed Couchbase sync server blocking port 80), but a notifying window appears twice showing the text “PHP Startup:” - nothing more. Starting Apache as a service does not show any hints.

Looking at the Apache error log, only the following is unusual:

Xdebug requires Zend Engine API version 220131226.
The Zend Engine API version 220121212 which is installed, is outdated.

Maybe this corresponds to the error window. Would make sense. But most probably this is not the reason for the problem in question, or is it? I understand that I should fetch an older version of Xdebug to fix this, but Xdebug is not the problem right now.


In C:\xampp\php\ext I find

php_couchbase.dll.140624 2014-06-24

which obviously is a version I could not work with earlier due to the aforementioned API mismatches (presumably with API 140624 - no, it stands for the date: 2014-06-24), and also

php_couchbase.dll 2015-01-21

which looks like being fresh from your very own workbench.

phpinfo() shows that the couchbase extension is not loaded with this (2015-01-21) version.

A quick test with the other version (2014-06-24) showed that Apache starts without complaint from the shell (so I guess I had problems with this one when I tested with PHP 5.6), and the Couchbase extension is loaded.

couchbase
Version 2.0

But don’t open the champagne yet: I have a totally different error message. First my code:

phpinfo();
$clusterConnection = new CouchbaseCluster(‘couchbase://localhost’);

Now the error which tells us equally well that the Couchbase system as such has been loaded.

Fatal error: Uncaught exception ‘CouchbaseException’ with message ‘Invalid arguments’ in CouchbaseNative:182 Stack trace: #0 CouchbaseNative(182): _CouchbaseCluster->__construct(‘couchbase://loc…’, ‘’, ‘’)

Using the sample code from couchbase.com:

$cb = new Couchbase(“127.0.0.1:8091”, “username”, “password”, “default”);

we get

Fatal error: Class ‘Couchbase’ not found


How and where can I find the right combination of PHP-version and php_couchbase.dll? This is a huge problem in it’s own.

github.com/maryo/php-5.5-windows-extensions (seems to be old)

pecl.php.net/package/couchbase/1.1.5/windows (version 1.x)

And that’s it. Google doesn’t give me any more hints.

Now let’s tackle with PHP first:

windows.php.net/download/
PHP 5.5 (5.5.21)
VC11 x64 Thread Safe (2015-Jan-22 03:12:55)

Let’s try this. Unfortunately, this version leads to an error:

Cannot load C:/xampp/php/php5ts.dll into server

because it is not a 32 bit application. Now what is this?

Okay, never mind, I’ll try it with PHP 32-bit:

VC11 x86 Thread Safe (2015-Jan-22 03:12:51)

Apache again starts without complaint from the shell. But my program says:

Fatal error: Class ‘Memcache’ not found

Looks like my version of ‘Memcache’ is not compatible with this one. Too bad. I remember finding the right version of memcached.dll wasn’t easy either. I’m not keen to dig into this mud once again.

As a quick hack, I put that one into coma, and finally here we have it in phpinfo():

couchbase
Version 2.0

This proves that php_couchbase.dll as of 2014-06-24 works with the latest php-5.5.21-Win32-VC11-x86 and 5.5.20 as well. Where did I get it from? I don’t remember.

And again:

Fatal error: Uncaught exception ‘CouchbaseException’ with message ‘Invalid arguments’ in CouchbaseNative:182 Stack trace: #0 CouchbaseNative(182): _CouchbaseCluster->__construct(‘couchbase://loc…’, ‘’, ‘’)


But wait – I’ll have to make sure that I have the latest libcouchbase.dll as well. Which one is the right one? Right now I use one with timestamp will 2013-10-22. Why this mismatch? An “outdated” libcouchbase.dll works with the latest PHP 5.5 and a php_couchbase.dll half a year old. Where does it come from?

From pecl.php.net/package/couchbase/1.1.5/windows I get

5.5 Thread Safe (TS) x86

with timestamp 2013-10-22. Obviously, libcouchbase.dll is taken from this package (php_couchbase-1.1.5-5.5-ts-vc11-x86.zip contains versions both of libcouchbase.dll and php_couchbase.dll from with date 2013-10-22).

This package however does not work (as expected), it yields no extension and Fatal error: Class ‘CouchbaseCluster’ …, so this is not the way to go.

Where did I get the latest php_couchbase.dll from? I didn’t take notice and I can’t find it anymore, Google or not.

But I did keep my unzipping directory (php_couchbase-2.0.3-5.5-zts-vc11-x64.zip), and there is no libcouchbase.dll provided (from the same source I discovered 2 days ago and can’t find today).

Would any version of libcouchbase.dll do? What does zts mean? As I also have php_couchbase-2.0.3-5.5-nts-vc11-x64.zip I must interpret this version as non-thread-safe, so the other (zts) should most probably be thread-safe.

Both package versions don’t contain libcouchbase.dll at all. What does this mean? Is the old version good enough so that there is no need to provide one? This doesn’t make sense as somebody could start with this version and not have any older package, so he wouldn’t have no libcouchbase.dll at all. Why is there no libcouchbase.dll in these packages?

Ah, here I got it from: pecl.php.net/package/couchbase – or not? No, this one is a tgz file, not a zip file as the other. Actually I downloaded this 2015-01-11 already in order to learn that this is the source code – of the client, that is.

The extension will become available via PECL once it leaves the DP phase. Until then, you may install by downloading a prebuilt binary of the DP available on couchbase.com for the Windows platform …

docs.couchbase.com/developer/c-2.4/download-install.html

You can install the C SDK from a repository for your platform, download prebuilt binaries, or compile from source.

No, you can’t, there are no prebuilt binaries.

Okay, I’ll be bold and just try to make up an address analogously to the other one: pecl.php.net/package/couchbase/2.0.3/windows – nope, no chance.

Looking at my download area, I find a directory libcouchbase-2.4.6.zip, downloaded 2 days ago from I don’t know where, which seems to be the source code (github.com/couchbase/libcouchbase/releases). I don’t think I’m going to compile this. Do I need it at all? Would make sense, or not?


I’m totally confused and lost. You are the expert. Can you make sense of all that?

Since I started investigating Couchbase, I spent many hours, in total a couple of days trying to set up Couchbase on my system, and in spite of this effort I didn’t learn that much. Too bad.

Is it all my fault? Am I just not clever enough for this kind of system? I don’t think so.

Obviously, there are some very serious organizational flaws which not only deprive me of valuable lifetime but also many others including the developers who try to help those poor guys daring to ask for help.

Of course I’d rather resolve this issue one way or another so this effort might not be totally wasted. For the moment I returned to PHP version 5.6.3 and got a very nice warning window:

PHP Startup: couchbase: Unable to initialize module
Module compiled with module API=20121212
PHP compiled with module API=20131226
These options need to match

This warning does not show with the latest version of php_couchbase.dll, but still the extension is not loaded. As PHP 5.6.x is not supported yet, I am not surprised.

The stub code obviously came from github.com/brett19/php-couchbase; alas, as vital parts are missing, I can’t help myself with this:

Fatal error: Class ‘_CouchbaseBucket’ not found


Well, no doubt someday later we’ll all have it running without problems, thanks to numerous people (or rather a few heroic ones, maybe only one after all, totally left on his own) who tirelessly and thanklessly serve the world (no irony intended).

So I’d better be patient and wait long enough. Or do you have an advice which cuts through all of this?


#10

Hey kklepper,

You are on the right track of identifying the correct php_couchbase extension to use. You can find all of the builds for 2.0.2 on windows here: http://docs.couchbase.com/developer/php-2.0/download-links.html. Additionally, you must download a copy of the C library (which is used internally by the PHP extension), as mentioned on the same page. You can find those downloads here: http://docs.couchbase.com/developer/c-2.4/download-install.html, you should match your visual studio version between the PHP extension and the C SDK.

Assuming this is your environment:
PHP 5.5 (5.5.21)
VC11 x64 Thread Safe (2015-Jan-22 03:12:55)

Here are the relevant download links you will need:
PHP Extension: http://sdk-snapshots.couchbase.com/php/php_couchbase-2.0.3-5.5-zts-vc11-x64.zip
C SDK Library: http://packages.couchbase.com/clients/c/libcouchbase-2.4.6_amd64_vc11.zip

P.S. I will start packaging a copy of the libcouchbase.dll with the PHP extension as soon as possible to help with set up.

Cheers, Brett


#11

Hey brett19, thanks a lot for your fast reply!

I’m afraid I’m not ready to compile as you suggest. The last time I compiled was during the 90s when I used to program in VC++ and Delphi. Although I learned that there is a free version of Visual Studio I could use, I estimate all of this will take too much time which I’d rather use otherwise, for example to expand my knowledge of Erlang and resume my experiments with Docker.

There are lots of options to satisfy our needs, Couchbase being one of them. Also, we are not in a hurry. I think I understood the possibilities of Couchbase, so I will come back whenever it seems appropriate.

By the way, the Couchbase guys did a very good job with their tutorial http://query.pub.couchbase.com/tutorial/#1 – I wish they likewise helped interested people to get their system up and running.

Again, thank you very much, I am really impressed about your commitment, not only in my case, of course.


#12

Hey kklepper,

The downloads I gave you do not involve any compiling. They are the pre-compiled dlls for you to use.

Cheers, Brett


#13

Hello Brett,

sorry that I misunderstood you and didn’t even look at the links you gave me; I guess the term SDK discouraged me.

These were the pages, I guess, I had found to be able to download the latest version of php_couchbase.dll. Now I also received the latest version of libcouchbase.dll. Very good.

I made sure that the latter was copied to both the php and apache/bin directories; the latest version of php_couchbase.dll was already in place in my PHP 5.5.21 installation. I checked that the extension php_couchbase.dll was set in php.ini.

Now the test: no extension. I’m sorry. And in consequence, of course,

Fatal error: Class ‘CouchbaseCluster’ not found.

Any advice? If you are sure it should work, what kind of fatal mistake could I possibly make?

Nothing in the Apache error.log. Interesting things in php_error_log:

[31-Jan-2015 00:56:37 UTC] PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20131226
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0

[31-Jan-2015 00:56:37 UTC] PHP Warning: PHP Startup: in Unknown on line 0

[31-Jan-2015 00:56:38 UTC] PHP Warning: PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20131226
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0

[31-Jan-2015 00:56:38 UTC] PHP Warning: PHP Startup: in Unknown on line 0

This should be explanation enough, right? But what must be done now? I have no clue.

Oh my, I’m silly! I already know that memcached has a problem. This notice doesn’t apply to Couchbase.

Regards, Karl


#14

Hey Karl,

Please remove the extension=php_memcache.dll (or similar) line from your php.ini as it is faulty and interfering with the proper startup of PHP.

Cheers, Brett


#15

Hey Brett,

This counsel is reasonable enough, but doesn’t change anything except the error message in php_error_log has changed to simply

PHP Fatal error: Class ‘CouchbaseCluster’ not found in xxx.php on line 637

Regards, Karl


#16

hello,
@keshav_katwe it has been now 5 days trying to make sdk php working and no chance
Fatal error: Class ‘CouchbaseCluster’ not found in C:\xampp\htdocs\wiss\testwiss.php on line 4

Why it is so difficult to make SDK php working for windows :frowning: (impossible in my case) ?
I donwloaded all DLL from here: https://github.com/keshavkatwe/couchbase
Installed xampp with php 5.5 32 bit on my windows 7 (64bit) , I have tried this call;

<?php // Connect to Couchbase Server $cluster = new CouchbaseCluster('http://127.0.0.1:8091'); $bucket = $cluster->openBucket('beer-sample'); // Retrieve a document $result = $bucket->get('aass_brewery-juleol'); $doc = $result->value; echo $doc->name . ', ABV: ' . $doc->abv . "\n"; // Store a document $doc->comment = 'Random beer from Norway'; $result = $bucket->replace('aass_brewery-juleol', $doc); var_dump($result); ?>

#17

@czajkowski Hello, I am little tired trying to mahe SDK PHP working on windows … can someone from Couchbase kindly help me ?