uc / qrcode-bundle
Symfony 3 扩展包,将 QRcode 集成到 Symfony 项目中
dev-master / 1.1.x-dev
2017-07-06 12:03 UTC
Requires
- php: >=7.1
- endroid/qrcode: ^2.2
- knplabs/knp-snappy-bundle: ~1.4
- sfk/email-template-bundle: dev-master
- symfony/symfony: ~3.0
This package is not auto-updated.
Last update: 2024-09-29 03:31:11 UTC
README
安装
要安装此扩展包,请运行以下命令,您将从 [Packagist][3] 获取最新版本。
@see https://github.com/Endroid/QrCode
composer require endroid/qrcode
然后在您的内核中启用它
// app/AppKernel.php public function registerBundles() { $bundles = [ // ... new Endroid\QrCode\Bundle\EndroidQrCodeBundle(), ]; }
@see https://github.com/KnpLabs/KnpSnappyBundle
使用 composer,添加
{ "require": { "knplabs/knp-snappy-bundle": "~1.4" } }
然后在您的内核中启用它
// app/AppKernel.php public function registerBundles() { $bundles = array( //... new Knp\Bundle\SnappyBundle\KnpSnappyBundle(), //...
并设置所需配置
# app/config/config.yml knp_snappy: pdf: enabled: true binary: /usr/local/bin/wkhtmltopdf #"\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe\"" for Windows users options: [] image: enabled: true binary: /usr/local/bin/wkhtmltoimage #"\"C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltoimage.exe\"" for Windows users options: []
composer require sfk/email-template-bundle dev-master
composer require uc/qrcode-bundle dev-master
在 AppKernel.php 中加载所需扩展包
// app/AppKernel.php public function registerBundles() { $bundles = array( // [...] new Uc\PaymentBundle\UcQCodeBundle(), ); }
创建 QRCode
/** * $vars = [ * 'code' => '' // Encode string, * 'orderId' => '' // Order ID * ] * @return string = '/uploads/tmp/orderId . date('dmY') .svg' // file location */ $QManager->generateQCode($vars = []);
生成 PDF
/** * $vars = [ * 'html' => '' //Html content which will be processed to pdf * 'name' => '' //PDF name * ] * @return array = [ * 'path' => '' //File location * 'pdf' => '' //PDF raw * ] */ $PDFManger->progressPDF($vars = []);
发送电子邮件
/** * $vars = [ * 'sender' => '' //Email sender * 'recipient' => '' //Email recipient * 'subject' => '' //Email subject * 'body' => '' //Email body * 'pdf' => '' //Attachment pdf file location * ] */ $DeliveryManager->onSendEmail($vars = []);