PHP code example of dolondro / google-authenticator

1. Go to this page and download the library: Download dolondro/google-authenticator 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/ */

    

dolondro / google-authenticator example snippets


$issuer = "MyAwesomeCorp";
$accountName = "MrsSmith";
$secretFactory = new SecretFactory();
$secret = $secretFactory->create($issuer, $accountName);

$googleAuth = new GoogleAuthenticator();
$googleAuth->authenticate($secret, $code);

$googleAuth = new GoogleAuthenticator();
$googleAuth->setCache($cacheItemPoolInterface);
$googleAuth->authenticate($secret, $code);
sh
php example.php
sh
php example.php mysecretcode