|
|
пре 1 година | |
|---|---|---|
| .github | пре 1 година | |
| .idea | пре 1 година | |
| .phpdoc | пре 1 година | |
| benchmark | пре 1 година | |
| docs | пре 1 година | |
| examples | пре 1 година | |
| src | пре 1 година | |
| tests | пре 1 година | |
| .editorconfig | пре 2 година | |
| .gitattributes | пре 1 година | |
| .gitignore | пре 1 година | |
| .readthedocs.yml | пре 2 година | |
| LICENSE-ASL-2.0 | пре 3 година | |
| LICENSE-MIT | пре 3 година | |
| NOTICE | пре 2 година | |
| README.md | пре 1 година | |
| composer.json | пре 1 година | |
| phpbench.json | пре 1 година | |
| phpcs.xml.dist | пре 1 година | |
| phpdoc.xml.dist | пре 2 година | |
| phpmd.xml.dist | пре 1 година | |
| phpstan-baseline.neon | пре 1 година | |
| phpstan.dist.neon | пре 1 година | |
| phpunit.xml.dist | пре 1 година |
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 on NPM: @chillerlan/qrcode.
ext-mbstringext-gd for QRGdImage based outputext-imagick with ImageMagick installedext-fileinfo required by QRImagick outputsetasign/fpdf for the PDF output moduleintervention/image for alternative GD/ImageMagick outputFor the QR Code reader, either ext-gd or ext-imagick is required!
QROptions container can be found here: chillerlan/php-settings-containerImportant: Please use the examples from the branch that matches your installed php-qrcode version ( v4.x, v5.x, dev-main )!
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&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.
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!
}
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!
The word "QR Code" is a registered trademark of DENSO WAVE INCORPORATED
https://www.qrcode.com/en/faq.html#patentH2Title