我正在使用CakePHP 3.4框架爲我的應用程序和endroid/qrcode生成器。php qr代碼無法正確顯示
在控制器中,我使用
use Endroid\QrCode\QrCode;
$qrCode = new QrCode();
$qrCode
->setText('Life is too short to be generating QR codes')
->setSize(300)
->setPadding(10)
->setErrorCorrection('high')
->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))
->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0))
->setLabel('Scan the code')
->setLabelFontSize(16)
->setImageType(QrCode::IMAGE_TYPE_PNG)
;
$this->set(compact('qrCode'));
,並鑑於
header('Content-Type: '.$qrCode->getContentType());
$qrCode->render(); ?>
但這渲染爲
可能是什麼問題,這是不顯示qr圖像?
你只是只渲染圖像?如果是這樣,您應該使用Response對象從控制器返回圖像。 – chrisShick
根據文檔提供者錯誤創建響應'Response class not found' –