Generate a QR code for a URL and save it as an SVG or PNG file inside a PHP application.
Embed a branded logo in the center of a QR code for use on marketing materials.
Expose a URL route in a Symfony app that generates QR codes on demand using the companion bundle.
Render QR codes directly inside HTML templates using the Twig extension.
Requires PHP 8+ and Composer, optional Symfony bundle and Twig extension add framework integration but are not needed for standalone use.
This is a PHP library for generating QR codes, which are the square barcodes commonly used to encode URLs and other short pieces of text that can be scanned by a phone camera. The library handles the math of building the QR code pattern and then outputs the result as an image file in a format you choose. The library supports several output formats: PNG, WebP, SVG, EPS, and PDF. You can control the size of the QR code, the amount of margin around it, the colors of the dark and light squares, and the error correction level. Error correction determines how much of the code can be damaged or obscured and still scan successfully. Higher correction means a more complex pattern but greater tolerance for things like printing defects or logos placed on top. Adding a logo image in the center of a QR code is supported directly. You provide an image path and a size, and the library places it over the code. Because the logo covers part of the pattern, the error correction level needs to be set high enough that the obscured portion does not prevent the code from scanning. The library also supports adding a text label below the QR code with control over font and alignment. For PHP projects using the Symfony framework there is a companion bundle that wires up QR code generation as a service and exposes URL routes for generating codes on request, which is useful for generating codes server-side in response to web requests. There is also a Twig extension for generating QR codes directly inside HTML templates. The library includes an optional validation step that, after generating a QR code, immediately decodes it and checks that the result matches the original input. This catches any rare cases where the generated code is unreadable, though it adds processing time so it is off by default. Installation uses Composer, the standard PHP package manager.
← endroid on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.