-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
The library is automatically set to return the following:
-
JSON strings
-
the default CouchDB URL
http://localhost:5984/
-
null CouchDB username and password details
The code snippet below shows how to alleviate the burden of dealing with JSON strings:
$db = new Chemem\Fauxton\DatabaseActions;
$db::setReturnType(false);
The setReturnType(bool)
method is configured with a boolean flag: true, the default option
returns JSON strings and false returns JSON-decoded arrays.
The CouchDB interaction URL can be set in the following manner:
$db = new Chemem\Fauxton\DatabaseActions;
$db::setCouchUrl('<your_url>');
Please enter a valid URL so as to enjoy your experience.
To use predefined authentication details, type the code shown below:
$db = new Chemem\Fauxton\DatabaseActions;
$db->useFauxtonLogin('<your_username>', '<your_password>');
Creating user details in Fauxton is one option and suits the example conveyed above, however, creating a valid username-password pair using the client is still possible. You can do it like this:
$db = new Chemem\Fauxton\DatabaseActions;
print_r($db->cookieCreateUser('<your_username>', '<your_password>'));
A third option, manipulating the _users database, is still within the realm of possibility though usage of this option has to be configured in the couch_db .ini file. To enter values in the _users database after making the aforementioned changes, type the following:
$db = new Chemem\Fauxton\DatabaseActions;
$db->authDbInsert('<your_username>', '<your_password>', 'user', [<roles>]);
print_r($db->getUserDetails('<your_username>', '<your_password>'));