Configuration - ace411/fauxton-client GitHub Wiki

Default 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

Changing configuration options

Returning a JSON-decoded array

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.

Setting the CouchDB URL

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.

Setting username and password details

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>'));

fauxton-client password generation tool

Consider using the QueryBuilder password generator tool to create a somewhat secure password from a relatively insecure hint. It can be done like this:

use Chemem\Fauxton\DatabaseActions;
use Chemem\Fauxton\QueryBuilder;

$db = new DatabaseActions;
$qBuilder = new QueryBuilder;
$password = $qBuilder->generatePassword(8, '123pass');
print_r($db->cookieCreateUser('<your_username>', $password));

An 8 character long string will be generated and used. This technique can persist since it returns the same password for each hint.

Resources

⚠️ **GitHub.com Fallback** ⚠️