installation
composer require endroid/qrcode
use:
use Endroid\QrCode\QrCode
Then this library to change it in the path: the path of your project \ vendor \ endroid \ qrcode \ src \ QrCode.php
changed
const LABEL_FONT_PATH_DEFAULT = '';
Code:
<? PHP namespace App \ ADMIN \ Controller; use Endroid \ QrCode \ QrCode; class QRC the extends Index { public function View () { $ qrcode = new new QrCode (); $ URL = ' https://www.baidu.com ' ; // add HTTP: // this scan code can jump directly URL $ qrCode-> the setText (URL $) -> the setSize ( 300 ) // size -> setLabelFontPath (VENDOR_PATH. ' endroid \ qrcode \ Assets \ noto_sans.otf ' ) ->setErrorCorrectionLevel('high') ->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0)) ->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0)) ->setLabel('推广码') ->setLabelFontSize(16); header('Content-Type: '.$qrCode->getContentType()); echo $qrCode->writeString(); exit; } }