Nenhuma descrição

smiley 3252ea6faa :shower: 1 ano atrás
.github 9ef0ba7b28 :octocat: update composer-install (https://github.com/ramsey/composer-install/pull/252) 1 ano atrás
.idea c8fd2b45dd :octocat: 2 anos atrás
.phan 054b76a631 :shower: remove phan stubs that have become unnecessary 2 anos atrás
.phpdoc 2f403df971 :sparkles: 2 anos atrás
docs 3252ea6faa :shower: 1 ano atrás
examples 00800ef901 :bath: clean-up (again) 2 anos atrás
src df49b3ffa4 :wrench: estimated bit length was correct, add a safety margin instead 1 ano atrás
tests 3252ea6faa :shower: 1 ano atrás
.editorconfig 826f9cfa65 :octocat: 2 anos atrás
.gitattributes 2aeb7b8b26 :sparkles: 2 anos atrás
.gitignore f6dc397a56 :sparkles: cheap performance tests 2 anos atrás
.readthedocs.yml 6a44b067ef :sparkles: fuck it, read the docs 2 anos atrás
LICENSE-ASL-2.0 66c0b69ffb :octocat: added Apache-2.0 license 3 anos atrás
LICENSE-MIT 66c0b69ffb :octocat: added Apache-2.0 license 3 anos atrás
NOTICE ff147426a1 :octocat: moved some files 2 anos atrás
README.md 900c8aea4f :octocat: point to examples in version branches (https://github.com/chillerlan/php-qrcode/discussions/241#discussioncomment-8461662) 1 ano atrás
composer.json e5ba986edb :octocat: 1 ano atrás
phpcs.xml.dist ffb2aa026f :octocat: 2 anos atrás
phpdoc.xml.dist 61bf95856a :octocat: 2 anos atrás
phpmd.xml.dist 5c37096c9d :octocat: 2 anos atrás
phpunit.xml.dist b915a1ec58 :octocat: 1 ano atrás

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": "^^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.

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