\CouchbaseClassicAuthenticator

Authenticator based on login/password credentials.

This authenticator uses separate credentials for Cluster management interface as well as for each bucket.

Examples

Cluster authentication

<?php
$authenticator = new \Couchbase\ClassicAuthenticator();
$authenticator->cluster('Administrator', 'password');
$authenticator->bucket('protected', 'secret');

$cluster = new \Couchbase\Cluster("couchbase://localhost");
$cluster->authenticate($authenticator);

$cluster->openBucket('protected'); // successfully opens connection
$cluster->manager()->createBucket('hello'); // automatically use admin credentials

Cross-bucket N1QL query

<?php
$authenticator = new \Couchbase\ClassicAuthenticator();
$authenticator->bucket('people', 'secret');
$authenticator->bucket('orders', '123456');

$cluster = new \Couchbase\Cluster("couchbase://localhost");
$cluster->authenticate($authenticator);

$bucket = $cluster->openBucket('orders');

$query = \Couchbase\N1qlQuery::fromString(
    "SELECT * FROM `orders` JOIN `people` ON KEYS `orders`.person_id ORDER BY `orders`.name");
$query->consistency(\Couchbase\N1qlQuery::REQUEST_PLUS);
$query->crossBucket(true);

$res = $bucket->query($query);
// $res inludes rows from orders and people buckets

Summary

Methods
Properties
Constants
cluster()
bucket()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

cluster()

cluster(string  $username, string  $password) 

Registers cluster management credentials in the container

Parameters

string $username

admin username

string $password

admin password

bucket()

bucket(string  $name, string  $password) 

Registers bucket credentials in the container

Parameters

string $name

bucket name

string $password

bucket password