Нет описания

smiley 7b66282572 :octocat: 1 месяц назад
.github 7b66282572 :octocat: 1 месяц назад
.idea 390393e97a :octocat: 3 месяцев назад
.phan 81291a4b6b :octocat: static analysis happy 1 год назад
.phpdoc 2f403df971 :sparkles: 2 лет назад
docs d98e9586f9 :book: 1 месяц назад
examples bc7ba5e22a :octocat: PHP 8.5 deprecation: imagedestroy() 1 месяц назад
src c90e011746 :shower: phan happy 1 месяц назад
tests 4c8da3b75c :octocat: dependency update 3 месяцев назад
.editorconfig 826f9cfa65 :octocat: 2 лет назад
.gitattributes 30c2d46878 :octocat: dependency & CI updates 1 год назад
.gitignore f6dc397a56 :sparkles: cheap performance tests 2 лет назад
.readthedocs.yml 6a44b067ef :sparkles: fuck it, read the docs 2 лет назад
LICENSE-ASL-2.0 66c0b69ffb :octocat: added Apache-2.0 license 3 лет назад
LICENSE-MIT 66c0b69ffb :octocat: added Apache-2.0 license 3 лет назад
NOTICE ff147426a1 :octocat: moved some files 2 лет назад
README.md 7229fdcb60 Merge remote-tracking branch 'origin/v5.0.x' into v5.0.x 1 год назад
composer.json 7b66282572 :octocat: 1 месяц назад
phpcs.xml.dist 07250c45a7 :octocat: dependency update 6 месяцев назад
phpdoc.xml.dist 61bf95856a :octocat: 2 лет назад
phpmd.xml.dist a54c1a56a0 :octocat: +phpmd command 1 год назад
phpunit.xml.dist 5dc99a4838 :octocat: 1 год назад

README.md

chillerlan/php-qrcode

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

Overview

Features

  • 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)

Requirements

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

Documentation

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!

Terminal

composer require chillerlan/php-qrcode

composer.json

{
	"require": {
		"php": "^7.4 || ^8.0",
		"chillerlan/php-qrcode": "v5.0.x-dev#<commit_hash>"
	}
}

Note: replace v5.0.x-dev with a version constraint, e.g. ^4.3 - see releases for valid versions.

Quickstart

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

$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';

// 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
try{
	$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!

Disclaimer!

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
https://www.qrcode.com/en/faq.html#patentH2Title