explaingit

endroid/qr-code

4,776PHPAudience · developerComplexity · 2/5Setup · easy

TLDR

A PHP library for generating QR codes in PNG, SVG, WebP, EPS, and PDF formats, with support for custom colors, logos in the center, text labels, and adjustable error correction levels.

Mindmap

mindmap
  root((qr-code))
    What It Does
      Generate QR codes
      Multiple output formats
      Add center logo
      Add text label
    Tech Stack
      PHP
      Composer
      Symfony bundle
      Twig extension
    Output Formats
      PNG and WebP
      SVG and EPS
      PDF
    Use Cases
      URL encoding
      Marketing materials
      Server-side web apps
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Generate a QR code for a URL and save it as an SVG or PNG file inside a PHP application.

USE CASE 2

Embed a branded logo in the center of a QR code for use on marketing materials.

USE CASE 3

Expose a URL route in a Symfony app that generates QR codes on demand using the companion bundle.

USE CASE 4

Render QR codes directly inside HTML templates using the Twig extension.

Tech stack

PHPComposerSymfonyTwig

Getting it running

Difficulty · easy Time to first run · 5min

Requires PHP 8+ and Composer, optional Symfony bundle and Twig extension add framework integration but are not needed for standalone use.

In plain English

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.

Copy-paste prompts

Prompt 1
Write a PHP script using endroid/qr-code to generate a QR code for https://example.com and save it as an SVG file with a custom blue-on-white color scheme.
Prompt 2
Show me how to use endroid/qr-code to add a company logo image to the center of a QR code and set the error correction level high enough that it still scans.
Prompt 3
How do I install and configure the endroid/qr-code Symfony bundle to expose a /qr/{data} route that generates QR codes from URL parameters?
Prompt 4
Write a Twig template snippet that renders a QR code inline as a base64 PNG using the endroid/qr-code Twig extension.
Prompt 5
How does the endroid/qr-code validation step work, and when should I enable it to check that a generated code is actually scannable?
Open on GitHub → Explain another repo

← endroid on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.