m

全干工程师

php快速生成炫酷二维码

安装依赖包

composer.json文件添加..


{
    "require": {
        "php": "^7.2",
        "chillerlan/php-qrcode": "dev-master"
    }
}

执行安装


composer install --no-dev

示例代码

以下是在phalcon框架中的使用


    ...

    public function qrcodeAction() {
        $qrcodeContent = $this->request->get('content');
        $options = new QROptions([
            'version'      => QRCode::VERSION_AUTO,
            'outputType'   => QRCode::OUTPUT_IMAGE_PNG,
            'eccLevel'     => QRCode::ECC_L,
            'scale'        => 6,
            'imageBase64'  => false,
        ]);
        $this->response->setContentType("image/png");
        return (new QRCode($options))->render($qrcodeContent);
    }

    ...

留言