Skip to content

Commit

Permalink
Enhance examples /w environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
joostfaassen committed Feb 25, 2016
1 parent 305a731 commit 1821385
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions examples/checkcredentials.php
Expand Up @@ -2,8 +2,12 @@

require_once ('common.php');

$username = 'username';
$password = 'password';
if (count($argv)!=3) {
echo "Please pass 2 parameters to check: username and password\n";
exit();
}
$username = $argv[1];
$password = $argv[2];

if ($client->checkCredentials($username, $password)) {
echo "CREDENTIALS OK\n";
Expand Down
16 changes: 16 additions & 0 deletions examples/common.php
@@ -0,0 +1,16 @@
<?php

require_once (__DIR__ . '/../vendor/autoload.php');

use UserBase\Client\Client;

$baseUrl = 'http://127.0.0.1:8888/api/v1';
$username = getenv('USERBASE_CLIENT_USERNAME');
$password = getenv('USERBASE_CLIENT_PASSWORD');

if (!$username || !$password) {
echo "Environment variables not yet properly configured\n";
exit();
}

$client = new Client($baseUrl, $username, $password);

0 comments on commit 1821385

Please sign in to comment.