~/docs
Resonate
Resonate
1.x 1.0.2, current
QR Code Generator
Toggle sidebar
QR Code Generator
webpatser/qr-code 1.0.2

QR Code Generator 1.x

Installation

Install webpatser/qr-code with Composer and check the PHP and image extension requirements.

A PHP library that generates QR codes as PNG, SVG and EPS, with nine code types (text, URL, email, phone, SMS, Wi-Fi, vCard, meCard and calendar event). The code is a restoration and modernization of a PHP QR code library whose original GitHub repository was deleted.

composer require webpatser/qr-code

Requirements

  • PHP 8.2 or higher.
  • The GD extension for PNG output (QR_Code::png() and the png() method on every type use GD).
  • The ImageMagick extension is optional. Only FastQRCode and UltraFastQRCode can use it as a rendering engine; see Performance.
  • composer.json requires only PHP. UltraFastQRCode also needs the zlib extension (usually bundled).

Verify the install

use QR_Code\Types\QR_Text;
 
$dataUri = (new QR_Text('Hello World!'))->png();
 
echo substr($dataUri, 0, 22); // data:image/png;base64,

Without an output file, png() returns the image as a data:image/png;base64,... string that you can use directly as an <img> source.

Generated on this server

These QR codes are generated by webpatser/qr-code on this documentation server, each with the code shown under it. The Examples page shows every type.

QR code: Text
Text
PNG
(new QR_Text('Hello World!'))->png();
QR code: URL
URL
PNG
(new QR_Url('https://github.com/webpatser/qr-code'))->png();
QR code: Email
Email
PNG
(new QR_EmailMessage('[email protected]', 'Hello from QR Code!', 'Test Subject'))->png();
QR code: Phone
Phone
PNG
(new QR_Phone('+1234567890'))->png();
QR code: Wi-Fi
Wi-Fi
PNG
(new QR_WiFi('WPA', 'MyNetwork', 'password123'))->png();
QR code: SMS
SMS
PNG
(new QR_Sms('+1234567890', 'Hello from QR!'))->png();

Next Steps

  • Quick Start: generate PNG and SVG output and set size, margin and colors.
  • Examples: one example per QR code type.
  • API Reference: constructors, configuration methods and utility classes.