codelint / qr-code
Fork From Endroid QR Code
Fund package maintenance!
endroid
Requires
- php: ^7.1.3
- ext-gd: *
- bacon/bacon-qr-code: ^2.0
- khanamiryan/qrcode-detector-decoder: ^1.0.2
- myclabs/php-enum: ^1.5
- symfony/http-foundation: ^3.4||^4.0
- symfony/options-resolver: ^3.4||^4.0
- symfony/property-access: ^3.4||^4.0
Requires (Dev)
- endroid/test: dev-master
- dev-master / 3.x-dev
- 3.7.2.2
- 3.7.2.1
- 3.7.2
- 3.7.1
- 3.7.0
- 3.6.1
- 3.6.0
- 3.5.8
- 3.5.7
- 3.5.6
- 3.5.5
- 3.5.4
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.9
- 3.4.8
- 3.4.7
- 3.4.6
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.12
- 3.2.11
- 3.2.10
- 3.2.9
- 3.2.8
- 3.2.7
- 3.2.6
- 3.2.5
- 3.2.4
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.x-dev
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.3.4
- 1.2.4
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- dev-hotfix-issue-192
This package is auto-updated.
Last update: 2024-11-12 06:11:13 UTC
README
By endroid
This library helps you generate QR codes in a jiffy. Makes use of bacon/bacon-qr-code to generate the matrix and khanamiryan/qrcode-detector-decoder for validating generated QR codes. Further extended with Twig extensions, generation routes, a factory and a Symfony bundle for easy installation and configuration.
Installation
Use Composer to install the library.
$ composer require endroid/qr-code
Basic usage
use Endroid\QrCode\QrCode; $qrCode = new QrCode('Life is too short to be generating QR codes'); header('Content-Type: '.$qrCode->getContentType()); echo $qrCode->writeString();
Advanced usage
use Endroid\QrCode\ErrorCorrectionLevel; use Endroid\QrCode\LabelAlignment; use Endroid\QrCode\QrCode; use Endroid\QrCode\Response\QrCodeResponse; // Create a basic QR code $qrCode = new QrCode('Life is too short to be generating QR codes'); $qrCode->setSize(300); // Set advanced options $qrCode->setWriterByName('png'); $qrCode->setMargin(10); $qrCode->setEncoding('UTF-8'); $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH()); $qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]); $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]); $qrCode->setLabel('Scan the code', 16, __DIR__.'/../assets/fonts/noto_sans.otf', LabelAlignment::CENTER()); $qrCode->setLogoPath(__DIR__.'/../assets/images/symfony.png'); $qrCode->setLogoSize(150, 200); $qrCode->setRoundBlockSize(true); $qrCode->setValidateResult(false); $qrCode->setWriterOptions(['exclude_xml_declaration' => true]); // Directly output the QR code header('Content-Type: '.$qrCode->getContentType()); echo $qrCode->writeString(); // Save it to a file $qrCode->writeFile(__DIR__.'/qrcode.png'); // Create a response object $response = new QrCodeResponse($qrCode);
Built-in validation reader
You can enable the built-in validation reader (disabled by default) by calling setValidateResult(true). This validation reader does not guarantee that the QR code will be readable by all readers but it helps you provide a minimum level of quality.
The readability of a QR code is primarily determined by the size, the input length, the error correction level and any possible logo over the image so you can tweak these parameters if you are looking for optimal results. You can also check $qrCode->getRoundBlockSize() value to see if block dimensions are rounded so that the image is more sharp and readable.
Take note that the validator can consume quite amount of additional resources.
Symfony integration
The endroid/qr-code-bundle integrates the QR code library in Symfony for an even better experience.
- Configure your defaults (like image size, default writer etc.)
- Generate QR codes quickly from anywhere via the factory service
- Generate QR codes directly by typing an URL like /qr-code/<text>.png?size=300
- Generate QR codes or URLs directly from Twig using dedicated functions
Read the bundle documentation for more information.
Versioning
Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.
License
This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.