A QR code generator and reader with a user friendly API. PHP 8.2+

5.0.2 2024-02-27 14:37 UTC


A PHP QR Code generator based on the implementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff.
It also features a QR Code reader based on a PHP port of the ZXing library.

Attention: there is now also a javascript port: chillerlan/js-qrcode.

PHP Version Support Packagist version Continuous Integration CodeCov Codacy Packagist downloads Documentation



  • Creation of Model 2 QR Codes, Version 1 to 40
  • ECC Levels L/M/Q/H supported
  • Mixed mode support (encoding modes can be combined within a QR symbol). Supported modes:
  • Flexible, easily extensible output modules, built-in support for the following output formats:
  • QR Code reader (via GD and ImageMagick)


For the QRCode reader, either ext-gd or ext-imagick is required!


Important: Please use the examples from the branch that matches your installed php-qrcode version ( v4.x, v5.x, dev-main )!

Installation with composer

See the installation guide for more info!


composer require chillerlan/php-qrcode


	"require": {
		"php": "^^8.2",
		"chillerlan/php-qrcode": "dev-main#<commit_hash>"

Note: replace dev-main with a version constraint, e.g. ^5.0 - see releases for valid versions.


We want to encode this URI for a mobile authenticator into a QRcode image:

$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&';

// quick and simple:
echo '<img src="'.(new QRCode)->render($data).'" alt="QR Code" />';

Wait, what was that? Please again, slower! See Advanced usage in the manual. Also, have a look in the examples folder for some more usage examples.

QR codes are awesome!

Reading QR Codes

Using the built-in QR Code reader is pretty straight-forward:

// it's generally a good idea to wrap the reader in a try/catch block because it WILL throw eventually
	$result = (new QRCode)->readFromFile('path/to/file.png'); // -> DecoderResult

	// you can now use the result instance...
	$content = $result->data;
	$matrix  = $result->getMatrix(); // -> QRMatrix

	// ...or simply cast it to string to get the content:
	$content = (string)$result;
catch(Throwable $e){
	// oopsies!

Shameless advertising

Hi, please check out some of my other projects that are way cooler than qrcodes!


I don't take responsibility for molten CPUs, misled applications, failed log-ins etc.. Use at your own risk!

License notice

Trademark Notice

The word "QR Code" is a registered trademark of DENSO WAVE INCORPORATED