Failed to create IO instance of Couchbase - php

I just change Couchbase 2.0beta for using Views.So,I follow the offical manual to build couchbase php extsion.
First,install a pure RHEL 6.2.Then,install couchbase-server-2.0.0-1723 and all dependent packages from libcouchbase:
libcouchbase2-dummy-2.0.0beta2-1.x86_64
couchbase-server-2.0.0-1723.x86_64
libcouchbase2-2.0.0beta2-1.x86_64
libcouchbase-devel-2.0.0beta2-1.x86_64
libev-4.03-3.el6.x86_64
libevent-1.4.13-1.el6.x86_64
Extract php-ext-couchbase-1.1.0-dp5-centos62-x86_64.tar.gz,copy couchbase.so to /usr/lib64/php/modules/,and edit /etc/php.d/json.ini:
extension=json.so
extension=couchbase.so
Finally,restart HTTP Server.Then,Check couchbase modules is lauch corrent by:
php -m|grep couchbase
and phpinfo() can output couchbase version is 1.1.0-dp5.
All looks well,but I try to run php code:
<?php
$cb = new Couchbase("127.0.0.1:8091",'Administrator','redflag','default');
$cb->set('a',1);
It's wrong:
$ php getview.php
PHP Warning: Couchbase::__construct(): failed to create IO instance in /var/www/html/getview.php on line 2
PHP Warning: Couchbase::set(): unintilized couchbase in /var/www/html/getview.php on line 3
In order to check couchbase setup is right,I open Couchbase GUI by Administrator as username,redflag as password.Then,create new document,use REST API get item or Views.Those things are OK,no problem,except php code.
No other way out,I git from https://github.com/couchbase/php-ext-couchbase. Build new php-couchbase extsion,and try agin.But the problem is the same.
I find someone has the same error on here & this.Unfortunately there was't solutions.
How can I use php-ext-couchbase 1.1dp5 modules?THX.

on a first glance it seems to load the couchbase extension properly. The thing that may be wrong here is how to access your bucket.
If you didn't do any changes, the "default" bucket has no password associated with it and in general the user of the bucket is the bucket name itself. So in the case of the "default" bucket, it would look like this:
$client = new Couchbase("127.0.0.1:8091", "default", "", "");
And if you have a password defined:
$client = new Couchbase("127.0.0.1:8091", "bucketname", "", "password");
Hope this helps,
Michael

Use yum to install libcouchbase2-libevent package can solve this problem.
BTW.While you run yum install libcouchbase-devel,it don't include libcouchbase2-libevent.If you miss that,you also can make & install php-ext-couchbase module with no error.But you can't connect Couchbase in php,as memtion above.

Related

PHP Version 7.3.17 on Amazon EC2 missing sodium?

When making call to sodium_crypto_pwhash_str I get the following in my Apache error log file.
PHP Fatal error: Uncaught Error: Call to undefined function
sodium_crypto_pwhash_str()
My php version, as noted is 7.3.17 running on an Amazon EC2 instance.
My php-info() does not return any relevant libsodium information other than module author info:
Sodium Frank Denis
Given the above author information references a module author am I supposed to enable the sodium module? If the answer is yes is it referenced in the php.ini file? Such as:
extension=sodium
or perhaps:
extension=libsodium
What am I missing here?
Am I not supposed to use the documented function sodium_crypto_pwhash_str?
Am I supposed to use some other method of accessing the desired functionality?
Yes normally it's included in PHP 7.2+ but when you use the AWS EC2 instances this is a bit minimalistic and not everything is included.
https://www.php.net/manual/de/sodium.installation.php
Here you can see that you have to enable it during the compiling with --with-sodium[=DIR]. So you can compile it on your own or you try another distro to get it from your package manager or you use another lib to make it work.
https://forums.aws.amazon.com/thread.jspa?threadID=293187

Error and warning connecting MongoDB to PHP using php_mongodb extension

I installed the MongoDB PHP driver on Windows 10 (I'm using WAMP equipped with PHP 5.6.25. following the istructions I found at http://php.net/manual/en/mongodb.installation.windows.php and I installed also the libbson and libmongoc libraries (requested as requirements) as written at http://php.net/manual/en/mongodb.requirements.php.
Then, I added the bin folders of MongoDB, libbson and libmongoc to system path.
However, even if I can see the php_mongodb extension in the extensions list of WAMP, launching phpinfo() the mongo extension doesn't appear with the others.
Furthermore, tryng to connect to my database with
<?php
$mongo=new MongoClient("");
$db=$mongo->galileo;
$collection= $db->items;
print_r("Number of documens: "); ?>
I got the error
Fatal error: Class 'MongoClient' not found in C:\wamp64\www\galileo\index.php >on line 21
At a first look, reading this error, it might seem like that PHP is looking for php_mongodb extension in the uncorrect folder i.e. C:\wamp64\www\galileo\index.php (where the index page of my project is placed) instead of the correct one C:\wamp64\bin\php\php5.6.25\ext where all the extensions are.
But, looking at php log file php_error.log I find also a warning that says:
PHP Warning: PHP Startup: Unable to load dynamic library 'c:/wamp64/bin/php/php5.6.25/ext/php_mongodb.dll' - Il sistema operativo non pu� eseguire %1.
in Unknown on line 0.
(for not Italian speaking, the phrase after - means the operating system can't execute %1, even if I can't imagine what %1 stands for).
Even using the new class MongoDB\Driver\Manager I get the error
Fatal error: Class 'MongoDB\Driver\Manager' not found in C:\wamp64\www\galileo\index.php on line 21
and the same warning.
Do you notice some error or forgetfulness in the installation process as I described and, if not, do you know how to fix the problem?
The problem is certainly related to WAMP and I think is related to the multiple php.ini in his folders. In fact, in the apache folder you can find a php.ini file that cannot be modified, otherwise nothing works at all; at the same time any changes made to the php.ini file in the php folder seems have no effect except making appear the mongodb extension in the extensions list.
So, I try using XAMPP, as suggested in this video tutorial and it works. Using Composer I was able to install also the PHP library and not only the driver.
you should not use 'MongoClient class' anymore, this extension that defines this class is deprecated. look at here.
instead, you should use MongoDB\Driver\Manager class. please read http://php.net/manual/en/class.mongodb-driver-manager.php.
and the setup must be like this in php:
$mongo = new MongoDB\Driver\Manager("mongodb://localhost:27017");
And if you still use the old class; you either need to install the old legacy extension (pecl install mongo) and use PHP 5.x, or update your code to use this new driver's classes as the old driver is not available for PHP 7. There is an upgrade guide at here.
the last part is from derickr's answer in this issue on github: https://github.com/mongodb/mongo-php-driver/issues/300

Phalcon Mongo Class not found error

I attempting to setup Phalcon PHP using a Mongo database connection. I have configured my bootstrap (index.php) file using the following:
// Mongo database connection
$di->set('mongo', function(){
$mongo = new Mongo();
return $mongo->selectDb("phalcon");
}, true);
// Collection Manager
$di->set('collectionManager', function(){
return new \Phalcon\Mvc\Collection\Manager();
});
Whenever I attempt execute an insert fucntion in using this connection, I receive a 500 Internal server error. Now, I have checked my apache server error logs and it states "PHP Fatal error: Class 'Mongo' not found in /var/www/phalcon-mongo/public/index.php on line 17".
I don't know why this request is not processing, according to the documentation given from Phalcon, the connection to mongo DB is setup up as I have displayed above.
If anyone has any advice, please let me know.
i think it's because your installation of Mongo is not valid.
try printing phpinfo() and check if mongo is loaded at all, if not - install it, add to ini files (if you use cli, don't forget to add to cli ini too) and reach the moment, when mongo is fully loaded.
try mongo w/o phalcon. any simple connection/insertation. you can see here: Fatal Error - 'Mongo' class not found that there are problems with apache module version for some people. Try reinstalling different mongo version.
if you can print this out:
echo Phalcon\Version::get();
there should be no problems with phalcon instalation
to validate mongo installation, try any of examples from php.net:
http://www.php.net/manual/en/mongo.tutorial.php
if both installations are valid, then there are problems with your custom code, but before doing anything you have to validate both installations.

Installing PHP Mongo Driver on Windows

I'm probably doing something silly here but I've been trying to install the mongodb php client on my windows VM running WAMP for a while and I've gotten nowhere.
I'm running WAMP 64 bit with PHP 5.4.3. I downloaded the 1.3.2RC1 zip from here and I extracted the php_mongo-1.3.2RC1-5.4-vc9.dll file into wamp/bin/php/php5.4.3/ext and then edited the php.ini file to include the new extension.
I restart WAMP and everything is fine, then when I try and use some of the code from the php mongo driver tutorial it says the MongoClient class cannot be found:
Fatal error: Class 'MongoClient' not found in C:\wamp\www\mongo\test.php ...
The code is simple but for completeness I'll include it:
<?php
$m = new MongoClient("the-connection-string-im-using");
?>
Am I missing something? Should I just be able to create a new instance of the MongoClient like above or do I need to do something else?
Cheers
James
I figured it out - I was using the wrong php.ini file. I should have been using the one in the apache directory (C:\wamp\bin\apache\apache2.2.22\bin).
Silly.

Php - Ingres, fresh install : How to debug?

I just finished to install Ingres on my server(only the client part, to connect to an existing ingres server), I just added the php_ingres module.
Now php recognize my module, so I tried to connect my self to several existing servers, but I always a
Unable to connect to database (Hostname here)
But with this I can't find what is wrong?? ingres error? Php driver? Credentials? ...?
What can I do to isolate these problem?
Most likely it's a user credentials issue. To see the actual error message use the following code:
$connection = ingres_connect(.....);
if (!is_resource($connection))
{
trigger_error(ingres_errno()." - ". ingres_error(),E_USER_ERROR);
}
You might also want to take a look at http://community.ingres.com/wiki/Ingres_with_Apache_on_Debian_Etch which outlines the setup steps for Ingres, PHP, Apache and Debian/Ubuntu.

Categories