PHP code example of hejunjie / google-authenticator
1. Go to this page and download the library: Download hejunjie/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/ */
hejunjie / google-authenticator example snippets
use Hejunjie\GoogleAuthenticator\GoogleAuthenticator;
$secret = GoogleAuthenticator::generateSecret();
// => "3PVPN3ASEIM457VR5VNUONDQB4"
use Hejunjie\GoogleAuthenticator\GoogleAuthenticator;
$issuer = 'MyApp'; // Application name
$label = '[email protected]'; // User identifier
$secret = '3PVPN3ASEIM457VR5VNUONDQB4';
// Basic usage (with default parameters)
GoogleAuthenticator::getQRCodeFile($issuer, $label, $secret, '/path/to/qrcode.png');
// Custom size and logo
GoogleAuthenticator::getQRCodeFile(
issuer: 'MyApp',
label: '[email protected]',
secret: $secret,
path: '/path/to/qrcode.png',
width: 400,
logo: '/path/to/logo.png',
logo_width: 60
);