1. Go to this page and download the library: Download battlerattle/doorman library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
battlerattle / doorman example snippets
use BattleRattle\Doorman\Authentication\TimeBasedAuthenticator;
// get the code from user input
$code = '...';
// the user's secret key
$key = '...';
$authenticator = new TimeBasedAuthenticator();
$result = $authenticator->authenticate($key, $code);
if ($result) {
echo 'Welcome, you successfully logged in';
} else {
echo 'Nope, please try again';
}
use BattleRattle\Doorman\Authentication\GoogleAuthenticator;
$code = '...';
$key = '...';
$authenticator = new GoogleAuthenticator();
$result = $authenticator->authenticate($key, $code);
if ($result) {
echo 'Welcome, you successfully logged in';
} else {
echo 'Nope, please try again';
}
use BattleRattle\Doorman\KeyGeneration\GoogleAuthKeyGenerator;
$keyGenerator = new GoogleAuthKeyGenerator;
$key = $keyGenerator->generateKey();
// it's good practice to split the key into chunks of 4 characters for better readability
$formattedKey = implode(' ', str_split($key, 4));
echo 'Add this key to your authenticator: ' . $formattedKey;
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.