Open-source PHP libraryQR Code Generator

QR codes that look like your brand.

PHP library for custom QR codes: module shapes, corner markers, a center logo and output to SVG, PNG, JPEG or WebP.

QR Code Generator: Open-source PHP library
QR Code Generator — On mobile
Year
2026
Role
Architecture, implementation, tests, documentation and demo page.
Stack
  • PHP 8.1+
  • SVG
  • GD
  • PHPUnit

The problem

PHP QR code libraries handle encoding well but give little control over how the code looks. Anyone who needs an on-brand QR code ends up reaching for JavaScript tools or third-party services.

By the numbers

  • 5built-in module shapes, plus custom ones
  • 4output formats: SVG, PNG, JPEG and WebP
  • 7layers, from encoding to validation
  • 0JavaScript needed for styling

What was built

  1. Encoding is delegated to bacon/bacon-qr-code; everything visual (layout, shapes, styling and rendering) lives in the library, in separate layers.

  2. Square, circle, rounded, diamond and “classy rounded” shapes, the last one reading neighboring modules to draw continuous corners.

  3. Custom shapes through a closure that returns an SVG path, with a readability validator.

  4. Independent styling for corner markers, their centers and each module type.

  5. A center logo with a reserved quiet area, rejecting sizes that would hurt scanning.

  6. An SVG path optimizer, a fluent API, a factory and a sample CLI.

In practice

<?php

use Tonsoo\QrCode\Styling\ModuleStyle;

$svg = qrCode('https://alysson-thoaldo.com.br')
    ->size(640)
    ->margin(32)
    ->foreground('#0f766e')
    ->modules(ModuleStyle::classyRounded(1.0))
    ->toSvg();

Screens

Outcome

Produces server-side, in plain PHP, the kind of styled QR code that used to require JavaScript in the browser. Available on Packagist, with an online generator to try it.

Contact

Have a project in mind?

Tell me what you need. I reply within two business days.

contato@alysson-thoaldo.com.brOpen the form