1. Go to this page and download the library: Download pragmarx/google2fa 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/ */
pragmarx / google2fa example snippets
use PragmaRX\Google2FA\Google2FA;
$google2fa = new Google2FA();
return $google2fa->generateSecretKey();
// Use your own QR Code generator to generate a data URL:
$google2fa_url = custom_generate_qrcode_url($qrCodeUrl);
/// and in your view:
<img src="{{ $google2fa_url }}" alt="">
<div class="visible-print text-center">
{!! QrCode::size(100)->generate($google2fa->getQRCodeUrl($companyName, $companyEmail, $secretKey)); !!}
<p>Scan me to return to the original page.</p>
</div>
$qrCode = new \Endroid\QrCode\QrCode($value);
$qrCode->setSize(100);
$google2fa_url = $qrCode->writeDataUri();
<div class="visible-print text-center">
{!! $google2fa_url !!}
<p>Scan me to return to the original page.</p>
</div>
use PragmaRX\Google2FA\Google2FA;
use BaconQrCode\Renderer\ImageRenderer;
use BaconQrCode\Renderer\Image\ImagickImageBackEnd;
use BaconQrCode\Renderer\RendererStyle\RendererStyle;
use BaconQrCode\Writer;
$google2fa = app(Google2FA::class);
$g2faUrl = $google2fa->getQRCodeUrl(
'pragmarx',
'[email protected]',
$google2fa->generateSecretKey()
);
$writer = new Writer(
new ImageRenderer(
new RendererStyle(400),
new ImagickImageBackEnd()
)
);
$qrcode_image = base64_encode($writer->writeString($g2faUrl));