Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork317
A PHP QR Code generator and reader with a user-friendly API.
License
Apache-2.0, MIT licenses found
Licenses found
chillerlan/php-qrcode
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A PHP QR Code generator based on theimplementation by Kazuhiko Arase, namespaced, cleaned up, improved and other stuff.
It also features a QR Code reader based on aPHP port of theZXing library.
Attention: there is now also a javascript port on NPM:@chillerlan/qrcode.
- Creation ofModel 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) asdefined in GBT18284-2000
- Flexible, easily extensible output modules, built-in support for the following output formats:
- GdImage (raster graphics: avif, bmp, gif, jpeg, png, webp)
- ImageMagick (multiple supported image formats)
- Markup types: SVG, HTML, etc.
- String types: JSON, plain text, etc.
- Encapsulated Postscript (EPS)
- PDF viaFPDF
- QR Code reader (via GD and ImageMagick)
- PHP 8.2+
ext-mbstring
- optional:
ext-gd
forQRGdImage
based outputext-imagick
withImageMagick installedext-fileinfo
required byQRImagick
outputsetasign/fpdf
for the PDF output moduleintervention/image
for alternative GD/ImageMagick output
For the QR Code reader, eitherext-gd
orext-imagick
is required!
- The user manual is athttps://php-qrcode.readthedocs.io/ (sources)
- An API documentation created withphpDocumentor can be found athttps://chillerlan.github.io/php-qrcode/
- The documentation for the
QROptions
container is here:chillerlan/php-settings-container - Benchmark results can be found in the
benchmark
branch
Important: Please use the examples from the branch that matches your installed php-qrcode version (v4.x,v5.x,dev-main)!
Themain
(default) branch is the active development for future major versions, and it is most likely incompatible with the latest release versions.
Installation withcomposer
Seethe installation guide for more info!
composer require chillerlan/php-qrcode
{"require": {"php":"^8.2","chillerlan/php-qrcode":"dev-main#<commit_hash>"}}
Note: replacedev-main
with aversion constraint, e.g.^5.0
- seereleases for valid versions.
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="'.(newQRCode)->render($data).'" alt="QR Code" />';
Wait, what was that? Please again, slower! SeeAdvanced usage in the manual.Also, have a lookin the examples folder for some more usage examples.
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 eventuallytry{$result = (newQRCode)->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!}
Hi, please check out some of my other projects that are way cooler than qrcodes!
- js-qrcode - a javascript port of this library
- php-authenticator - a Google Authenticator implementation (seeauthenticator example)
- php-httpinterface - a PSR-7/15/17/18 implemetation
- php-oauth - an OAuth 1/2 client library, fully PSR-7/PSR-17/PSR-18 compatible
- php-database - a database client & querybuilder for MySQL, Postgres, SQLite, MSSQL, Firebird
- php-tootbot - a Mastodon bot library (see@dwil)
I don't take responsibility for molten CPUs, misled applications, failed log-ins etc.. Use at your own risk!
- Parts of this code areported to PHP from theZXing project and licensed under theApache License, Version 2.0.
- The documentation is licensed under theCreative Commons Attribution 4.0 International (CC BY 4.0) License.
The word "QR Code" is a registered trademark ofDENSO WAVE INCORPORATED
https://www.qrcode.com/en/faq.html#patentH2Title
About
A PHP QR Code generator and reader with a user-friendly API.
Topics
Resources
License
Apache-2.0, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.