I installed a new Couchbase server 5.
On another server, I installed the PHP 7 and cli v2.3.4.
Now when I try to write data, I get an error.
If I do this:
$bucketName = "logs";
$cluster = new CouchbaseCluster("couchbase://192.168.0.51");
$authenticator5 = new \Couchbase\ClassicAuthenticator();
$authenticator5->bucket('Administrator', 'Pass');
$cluster->authenticate($authenticator5);
$bucket = $cluster->openBucket($bucketName);
// Store a document
echo "Storing 0:king_arthur\n";
$result = $bucket->upsert('0:king_arthur', array(
"email" => "kingarthur@couchbase.com",
"interests" => array("African Swallows")
));
var_dump($result);
Error:
Fatal error: Uncaught Couchbase\Exception: LCB_AUTH_ERROR: Authentication failed. You may have provided an invalid username/password combination in /var/www/html/system/test/cb5test1.php:20 Stack trace: #0 /var/www/html/system/test/cb5test1.php(20): Couchbase\Cluster->openBucket('logs') #1 {main} thrown in /var/www/html/system/test/cb5test1.php on line 20
$cluster = new CouchbaseCluster($clusterLogs5);
$cluster->authenticate('Administrator', 'Pass');
return $cluster->openBucket("bucketName");
I get an error:
Warning: Couchbase\Cluster::authenticate() expects exactly 1 parameter, 2 given in /var/www/... on line ..
Fatal error: Uncaught Couchbase\Exception: LCB_AUTH_ERROR: Authentication failed. You may have provided an invalid username/password combination
authenticateAs() is a shortcut. and there no really difference if you use PasswordAuthenticator. Maybe in some cases you want to create authenticator before cluster object, and feed it to multiple instances.