PHP 生成二维码
$ composer require endroid/qr-code 3.9.1
这里是下载版本 我指定了版本 最新版本不行的 可以试试此版本
$qrCode = new QrCode('hello world');
$qrCode->setSize(150);
$qrCode->setMargin(2);
$qrCode->setWriterByName('png');
$qrCode->setEncoding('UTF-8');
$qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]);
$qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]);
header('Content-Type: ' . $qrCode->getContentType());
$name = 'c' . time() . round(1000, 9999) . '.png';
$path = '/qrcode/' . date('Y-m-d') . '/' . $name;
$filename = ROOT_PATH.'public'.$path;
$dir = dirname($filename);
@mkdir($dir, 0777, true);
$qrCode->setLogoWidth(64);
$qrCode->writeFile($filename);
$this->success('生成成功',$path);