1、通過composer加載
php?composer.phar?require?"2amigos/yii2-qrcode-helper"?"*"
或者添加
"2amigos/yii2-qrcode-helper"?:?"*"
到對應項目的composer.json文件中。
(推薦教程:yii框架)
2、編輯/vendor/yiisoft/extensions.php,添加以下代碼到數組中
'2amigos/yii2-qrcode-helper'?=>? ???array?( ????'name'?=>?'2amigos/yii2-qrcode-helper', ????'version'?=>?'1.0.2.0', ????'alias'?=>? ????array?( ?????'@dosamigos/qrcode'?=>?$vendorDir?.?'/2amigos/yii2-qrcode-helper/src', ????), ?),
3、在你的控制器中添加以下代碼
use?dosamigosqrcodeQrCode;??//引入類 ?...? public?function?actionQrcode()? {? ??return?QrCode::png('http://www.yii-china.com');??//調用二維碼生成方法 } public?function?actionDemo() { ??return?$this->render('index'); }
在你的頁面中添加以下代碼 (demo/index)
@@##@@"?/>
訪問demo這個方法就能看到一張漂亮的二維碼了。
更多編程相關內容,請關注php中文網yii框架欄目!
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END