PHP couchbase集成仅在phpinfo()中显示版本号


PHP couchbase integration just shows version number only in phpinfo()

我曾尝试在centOS 6.5机器中将couchbase与PHP集成。并按照他们在"http://www.couchbase.com/communities/php/getting-started".但我无法从PHP连接到couchbase。当我检查phpinfo()时,它只显示了couchbase扩展的版本号。没有显示配置信息。

他们的示例代码不再有效,他们需要更新自己的网站。这是他们的原始代码:

<?php
// adjust these parameters to match your installation
$cb = new Couchbase("127.0.0.1:8091", "", "", "default");
$cb->set("a", 101);
var_dump($cb->get("a"));
?>

要设置新的数据桶,请转到您的网站地址:http://127.0.0.1:8091/index.html

或者在命令行中键入以下内容:

curl -X POST -d name=default -d ramQuotaMB=200 -d authType=none -d replicaNumber=2 -d proxyPort=11215 http://127.0.0.1:8091/pools/default/buckets

然后你需要调用CouchbaseCluster而不是Couchbase,如下所示:

<?php
// adjust these parameters to match your installation
$cb = new CouchbaseCluster("127.0.0.1:8091", "", "");
$db = $cb->openBucket("default");
$db->upsert("a", array("value" => 10));
$var_a = $db->get("a");
var_dump($var_a->value);
?>

你的输出应该是这样的:

object(stdClass)#4 (1) { ["value"]=> int(10) }