We use Cookies to ensure that we give you the best experience on our website. Read our Privacy Policy.
REJECT ALL COOKIESI AGREE
Open Source
Open Source - Library

QR Code Library Service

Visit Our Github Repository
By
2am.
June 19, 2024
6 min read
This library provides developers with the tools to generate QR codes with ease on their PHP Applications. It is a total refactored version of the previous library named yii2-qrcode-helper, which was based on the PHP version of the C library libqrencode. This new version is highly inspired by the great work of BaconQRCode, in fact, it uses a modified version of its code for the writers included in this package.

Getting Started

Install the latest version using composer.

$ composer require 2amigos/qrcode-library

Or simply add it to your compose.json file:

"2amigos/qrcode-library": "^2.0"

Usage

As standalone library:

1<?php
2use Da\QrCode\QrCode; 
3$qrCode = (new QrCode('This is my text'))
4	->setSize(250)
5	->setMargin(5)
6	->useForegroundColor(51, 153, 255);
7
8// now we can display the qrcode in many ways
9// saving the result to a file (writer defaults to PNG):
10$qrCode->writeFile(__DIR__ . '/code.png');
11
12// display directly to the browser
13header('Content-Type: '.$qrCode->getContentType());
14echo $qrCode->writeString();
15?>
16
17<?php
18// or even as data:uri url
19echo '<img src="' . $qrCode->writeDataUri() . '">';
20?>

In order to ease the task to write different formats, the library comes with a series of handy:

Yii2

This library comes also with two classes to work with the Yii2 framework. These are:

Contributors

Thank you all for your invaluable efforts!

Share This Post
Back to Open Source
Don't miss out on
our latest insights
– Subscribe Now!
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Navigate
Start Now