Skip to content

QR Codes

Đorđe Jocić edited this page Jan 7, 2019 · 3 revisions

Currently, you can only generate QR code remotely by utilizing Google's API. Upcoming version will change that, but until that happens, use the following snippet.

$qr = new Jocic\GoogleAuthenticator\Qr\Remote\GoogleQr(200, "/my/storage/directory");

$qrAbsoluteLocation = $qr->getFileLocation($account);
$qrRelativeLocation = $qr->getFilename($account);

$encodedValue = $qr->getEncodedValue($account);

$qrUrl = $qr->getUrl($account); // Possible Without Storage Location

You can, of course, always just instantiate an object and set parameters later.

$qr = new Jocic\GoogleAuthenticator\Qr\Remote\GoogleQr();

$qr->setQrCodeSize(200);
$qr->setStorageDirectory("/my/storage/directory");

$qrAbsoluteLocation = $qr->getFileLocation($account);
$qrRelativeLocation = $qr->getFilename($account);

$encodedValue = $qr->getEncodedValue($account);

$qrUrl = $qr->getUrl($account); // Possible Without Storage Location

QR codes are generated only once, when the location is initially requested, but you can always regenerate them if something goes wrong using the "regenerate" method. Also, keep in mind that, using the "generate" method before requesting QR code's location may improve overall performance if implemented correctly.

Clone this wiki locally