Issue
I find many solutions for CI3 on the web, but none works for CI4.
I installed a package using composer
composer require chillerlan/php-qrcode
Then I added a new Controller
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
class Qr extends BaseController
{
public function index($path)
{
$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
echo '<img src="' . (new QRCode)->render($data) . '" alt="QR Code" />';
}
}
This gives me Undefined type 'App\Controllers\QRCode'.
for the new QRCode
.
What do I need to do, to use the QRCode class?
Solution
Try this
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use chillerlan\QRCode\{QROptions, QRCode};
class Qr extends BaseController
{
public function index($path)
{
$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';
echo '<img src="' . (new QRCode)->render($data) . '" alt="QR Code" />';
}
}
Answered By - WiatroBosy Answer Checked By - Willingham (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.