Implementation code of YII2.0 framework to generate QR code function

Source: Internet
Author: User
installation via composer :

1. The following method is loaded via composer


PHP Composer.phar require "2amigos/yii2-qrcode-helper" "*"

or add


"2amigos/yii2-qrcode-helper": "*"

To the Composer.json file of the corresponding project

To install through an archive file:

Not accustomed to use composer users can click here to download the QR code extension .

Then unzip, change the file name to yii2-qrcode-helper into the vendor/2amigos/directory

Edit/vendor/yiisoft/extensions.php, add the following code to the array


' 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 ',    ),),

Usage

Add the code to your controller


Use Dosamigos\qrcode\qrcode;  Introduce class \ \ ... public function Actionqrcode () {   return QRCode::p ng (' http://www.yii-china.com ');  Call the two-dimensional code generation method}public function Actiondemo () {  return $this->render (' Index ');}

Add the following code to your page (Demo/index)


Access Demo This way, you can see a beautiful two-dimensional code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.