composer require sonata-project/google-authenticator or https:
include_once 'vendor/sonata-project/google-authenticator/src/FixedBitNotation.php';
include_once 'vendor/sonata-project/google-authenticator/src/GoogleAuthenticatorInterface.php';
include_once 'vendor/sonata-project/google-authenticator/src/GoogleAuthenticator.php';
include_once 'vendor/sonata-project/google-authenticator/src/GoogleQrUrl.php';
$g = new \Google\Authenticator\GoogleAuthenticator();
$secret = 'XVQ2UIGO75XRUKJO';
echo '<img src="'.$g->getURL('user', 'mywebsite.com', $secret).'" />';
$secret = 'XVQ2UIGO75XRUKJO';
$code = '010989';
if($g->checkCode($secret, $code)){
echo 'Authorized!';
}
else{
echo 'Incorrect or expired code!';
}