説明なし

smiley ff147426a1 :octocat: moved some files 2 年 前
.github 3ad6b70d78 :octocat: + documentation issue template 2 年 前
.idea c8fd2b45dd :octocat: 2 年 前
.phan ab358f2f38 :octocat: fixes/implements #223 2 年 前
.phpdoc 2f403df971 :sparkles: 2 年 前
docs 6a26d3afb8 :book: 2 年 前
examples 334fe5a42f :shower: phpcs happy 2 年 前
src ff147426a1 :octocat: moved some files 2 年 前
tests ff147426a1 :octocat: moved some files 2 年 前
.editorconfig 826f9cfa65 :octocat: 2 年 前
.gitignore 826f9cfa65 :octocat: 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 f72802c612 :octocat: 2 年 前
composer.json efeaa55dee :octocat: 2 年 前
phpcs.xml.dist ffb2aa026f :octocat: 2 年 前
phpdoc.xml.dist 61bf95856a :octocat: 2 年 前
phpmd.xml.dist 5c37096c9d :octocat: 2 年 前
phpunit.xml.dist 8173bc35c2 :octocat: use PHPUnit 9.6 schema 2 年 前

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.

Hi! Please check out the v5.0-beta release and leave your feedback in this discussion thread. Thanks!

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:
    • numeric
    • alphanumeric
    • 8-bit binary
    • 13-bit double-byte:
    • kanji (Japanese, Shift-JIS)
    • hanzi (simplified Chinese, GB2312/GB18030) as defined in GBT18284-2000
  • Flexible, easily extensible output modules, built-in support for the following output formats:
    • GdImage
    • ImageMagick
    • Markup types: SVG, HTML, etc.
    • String types: JSON, plain text, etc.
    • Encapsulated Postscript (EPS)
    • PDF via FPDF
  • QR Code reader (via GD and ImageMagick)

Requirements

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

Documentation

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": "dev-main#<commit_hash>"
	}
}

Note: replace dev-main 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