$r, 'g' => $g, 'b' => $b]; // 背景色 list($r, $g, $b) = sscanf($params['background']??'#ffffff', "#%02x%02x%02x"); $backgroundcolor = ['r' => $r, 'g' => $g, 'b' => $b]; // 创建实例 $qrCode = new \Endroid\QrCode\QrCode($params['text']??request()->domain().'/addons/pickup#/pages/index/index'); $qrCode->setSize($params['size']??250); // 高级选项 $qrCode->setWriterByName($params['format']??'png'); $qrCode->setMargin($params['padding']??10); $qrCode->setEncoding('UTF-8'); $qrCode->setErrorCorrectionLevel(new ErrorCorrectionLevel($params['errorlevel']??'quartile')); $qrCode->setForegroundColor($foregroundcolor); $qrCode->setBackgroundColor($backgroundcolor); $qrCode->setRoundBlockSize(true); $qrCode->setValidateResult(false); $qrCode->setWriterOptions(['exclude_xml_declaration' => true]); return $qrCode; } }