PHPackages                             racinepilote/qr-code - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. racinepilote/qr-code

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

racinepilote/qr-code
====================

Endroid QR Code v2

4.5.1(4y ago)04MITPHPPHP ^7.4||^8.0

Since Oct 27Pushed 4y agoCompare

[ Source](https://github.com/racinepilote/qr-code)[ Packagist](https://packagist.org/packages/racinepilote/qr-code)[ Docs](https://github.com/racinepilote/qr-code)[ GitHub Sponsors](https://github.com/endroid)[ RSS](/packages/racinepilote-qr-code/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (4)Versions (159)Used By (0)

QR Code
=======

[](#qr-code)

*By [endroid](https://endroid.nl/)*

[![Latest Stable Version](https://camo.githubusercontent.com/10e6b23b667743473662e47eb09fb5137e08d015f5ecf13964d07816057738ec/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656e64726f69642f71722d636f64652e737667)](https://packagist.org/packages/endroid/qr-code)[![Build Status](https://github.com/endroid/qr-code/workflows/CI/badge.svg)](https://github.com/endroid/qr-code/actions)[![Total Downloads](https://camo.githubusercontent.com/5387d9dc0b9b66f5c2979706fe5ca33ac50e9625fb41ac46bc0d22bcfa7920c8/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656e64726f69642f71722d636f64652e737667)](https://packagist.org/packages/endroid/qr-code)[![Monthly Downloads](https://camo.githubusercontent.com/029d2d3560d7848ca4368b3b98283dc21d69e05ddfd935dd2490bb0517c777fb/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f656e64726f69642f71722d636f64652e737667)](https://packagist.org/packages/endroid/qr-code)[![License](https://camo.githubusercontent.com/63e8babee0b0722d422d24d28f3a961496da2ec9d0dd7ee29a57282f9dcee283/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656e64726f69642f71722d636f64652e737667)](https://packagist.org/packages/endroid/qr-code)

This library helps you generate QR codes in a jiffy. Makes use of [bacon/bacon-qr-code](https://github.com/Bacon/BaconQrCode)to generate the matrix and [khanamiryan/qrcode-detector-decoder](https://github.com/khanamiryan/php-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. Different writers are provided to generate the QR code as PNG, SVG, EPS or in binary format.

Installation
------------

[](#installation)

Use [Composer](https://getcomposer.org/) to install the library.

```
$ composer require racinepilote/qr-code
```

Usage: using the builder
------------------------

[](#usage-using-the-builder)

```
use Endroid\QrCode\Builder\Builder;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh;
use Endroid\QrCode\Label\Alignment\LabelAlignmentCenter;
use Endroid\QrCode\Label\Font\NotoSans;
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
use Endroid\QrCode\Writer\PngWriter;

$result = Builder::create()
    ->writer(new PngWriter())
    ->writerOptions([])
    ->data('Custom QR code contents')
    ->encoding(new Encoding('UTF-8'))
    ->errorCorrectionLevel(new ErrorCorrectionLevelHigh())
    ->size(300)
    ->margin(10)
    ->roundBlockSizeMode(new RoundBlockSizeModeMargin())
    ->logoPath(__DIR__.'/assets/symfony.png')
    ->labelText('This is the label')
    ->labelFont(new NotoSans(20))
    ->labelAlignment(new LabelAlignmentCenter())
    ->build();
```

Usage: without using the builder
--------------------------------

[](#usage-without-using-the-builder)

```
use Endroid\QrCode\Color\Color;
use Endroid\QrCode\Encoding\Encoding;
use Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Label\Label;
use Endroid\QrCode\Logo\Logo;
use Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin;
use Endroid\QrCode\Writer\PngWriter;

$writer = new PngWriter();

// Create QR code
$qrCode = QrCode::create('Data')
    ->setEncoding(new Encoding('UTF-8'))
    ->setErrorCorrectionLevel(new ErrorCorrectionLevelLow())
    ->setSize(300)
    ->setMargin(10)
    ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
    ->setForegroundColor(new Color(0, 0, 0))
    ->setBackgroundColor(new Color(255, 255, 255));

// Create generic logo
$logo = Logo::create(__DIR__.'/assets/symfony.png')
    ->setResizeToWidth(50);

// Create generic label
$label = Label::create('Label')
    ->setTextColor(new Color(255, 0, 0));

$result = $writer->write($qrCode, $logo, $label);
```

Usage: working with results
---------------------------

[](#usage-working-with-results)

```
// Directly output the QR code
header('Content-Type: '.$result->getMimeType());
echo $result->getString();

// Save it to a file
$result->saveToFile(__DIR__.'/qrcode.png');

// Generate a data URI to include image data inline (i.e. inside an  tag)
$dataUri = $result->getDataUri();
```

[![QR Code](https://camo.githubusercontent.com/63378024cc77814ff2b761f3f06830ff96172f3ef856fbdaa720189da90cfadc/68747470733a2f2f656e64726f69642e6e6c2f71722d636f64652f64656661756c742f4c6966652532306973253230746f6f25323073686f7274253230746f253230626525323067656e65726174696e672532305152253230636f646573)](https://camo.githubusercontent.com/63378024cc77814ff2b761f3f06830ff96172f3ef856fbdaa720189da90cfadc/68747470733a2f2f656e64726f69642e6e6c2f71722d636f64652f64656661756c742f4c6966652532306973253230746f6f25323073686f7274253230746f253230626525323067656e65726174696e672532305152253230636f646573)

### Writer options

[](#writer-options)

```
use Endroid\QrCode\Writer\SvgWriter;

$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]);
```

### Encoding

[](#encoding)

If you use a barcode scanner you can have some troubles while reading the generated QR codes. Depending on the encoding you chose you will have an extra amount of data corresponding to the ECI block. Some barcode scanner are not programmed to interpret this block of information. To ensure a maximum compatibility you can use the `ISO-8859-1` encoding that is the default encoding used by barcode scanners (if your character set supports it, i.e. no Chinese characters are present).

### Round block size mode

[](#round-block-size-mode)

By default block sizes are rounded to guarantee sharp images and improve readability. However some other rounding variants are available.

- `margin (default)`: the size of the QR code is shrunk if necessary but the size of the final image remains unchanged due to additional margin being added.
- `enlarge`: the size of the QR code and the final image are enlarged when rounding differences occur.
- `shrink`: the size of the QR code and the final image are shrunk when rounding differences occur.
- `none`: No rounding. This mode can be used when blocks don't need to be rounded to pixels (for instance SVG).

Readability
-----------

[](#readability)

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-&gt;getRoundBlockSize() value to see if block dimensions are rounded so that the image is more sharp and readable. Please note that rounding block size can result in additional padding to compensate for the rounding difference. And finally the encoding (default UTF-8 to support large character sets) can be set to `ISO-8859-1` if possible to improve readability.

Built-in validation reader
--------------------------

[](#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. Take note that the validator can consume quite amount of additional resources and it should be installed separately only if you use it.

Symfony integration
-------------------

[](#symfony-integration)

The [endroid/qr-code-bundle](https://github.com/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.)
- Support for multiple configurations and injection via aliases
- Generate QR codes for defined configurations via URL like /qr-code//Hello
- Generate QR codes or URLs directly from Twig using dedicated functions

Read the [bundle documentation](https://github.com/endroid/qr-code-bundle)for more information.

Versioning
----------

[](#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
-------

[](#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.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity87

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~21 days

Recently: every ~14 days

Total

157

Last Release

1646d ago

Major Versions

2.5.0 → 3.0.02017-12-03

2.5.1 → 3.3.02018-08-17

2.x-dev → 3.9.42020-11-27

3.9.6 → 4.0.02021-02-28

3.9.7 → 4.1.32021-04-26

PHP version history (7 changes)1.0.0PHP &gt;=5.3.0

1.8.0PHP &gt;=5.4

2.0.0PHP &gt;=5.6

3.0.0PHP &gt;=7.1

3.6.0PHP &gt;=7.2

4.0.0PHP ^7.3||^8.0

4.4.0PHP ^7.4||^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4afaf821cbc793deadc52f30afacf70b001c04d6faa2524f085e503321108c2d?d=identicon)[racinepilote](/maintainers/racinepilote)

---

Top Contributors

[![endroid](https://avatars.githubusercontent.com/u/537253?v=4)](https://github.com/endroid "endroid (341 commits)")[![sprain](https://avatars.githubusercontent.com/u/260361?v=4)](https://github.com/sprain "sprain (9 commits)")[![MaximilianKresse](https://avatars.githubusercontent.com/u/545671?v=4)](https://github.com/MaximilianKresse "MaximilianKresse (7 commits)")[![ThomasLandauer](https://avatars.githubusercontent.com/u/1054469?v=4)](https://github.com/ThomasLandauer "ThomasLandauer (4 commits)")[![racinepilote](https://avatars.githubusercontent.com/u/3688898?v=4)](https://github.com/racinepilote "racinepilote (4 commits)")[![juuuuuu](https://avatars.githubusercontent.com/u/1769769?v=4)](https://github.com/juuuuuu "juuuuuu (3 commits)")[![edorfaus](https://avatars.githubusercontent.com/u/112590?v=4)](https://github.com/edorfaus "edorfaus (2 commits)")[![Runrioter](https://avatars.githubusercontent.com/u/1078011?v=4)](https://github.com/Runrioter "Runrioter (2 commits)")[![ice6](https://avatars.githubusercontent.com/u/889040?v=4)](https://github.com/ice6 "ice6 (2 commits)")[![JohannCOSTE](https://avatars.githubusercontent.com/u/19409426?v=4)](https://github.com/JohannCOSTE "JohannCOSTE (2 commits)")[![thijskh](https://avatars.githubusercontent.com/u/3808792?v=4)](https://github.com/thijskh "thijskh (2 commits)")[![marcosgdf](https://avatars.githubusercontent.com/u/168744?v=4)](https://github.com/marcosgdf "marcosgdf (1 commits)")[![rexmolo](https://avatars.githubusercontent.com/u/9864232?v=4)](https://github.com/rexmolo "rexmolo (1 commits)")[![Slamdunk](https://avatars.githubusercontent.com/u/152236?v=4)](https://github.com/Slamdunk "Slamdunk (1 commits)")[![smurfy](https://avatars.githubusercontent.com/u/805790?v=4)](https://github.com/smurfy "smurfy (1 commits)")[![spaze](https://avatars.githubusercontent.com/u/1966648?v=4)](https://github.com/spaze "spaze (1 commits)")[![Spomky](https://avatars.githubusercontent.com/u/1091072?v=4)](https://github.com/Spomky "Spomky (1 commits)")[![theianjohnson](https://avatars.githubusercontent.com/u/4634364?v=4)](https://github.com/theianjohnson "theianjohnson (1 commits)")[![AlexKovalevych](https://avatars.githubusercontent.com/u/577231?v=4)](https://github.com/AlexKovalevych "AlexKovalevych (1 commits)")[![Woodehh](https://avatars.githubusercontent.com/u/6039482?v=4)](https://github.com/Woodehh "Woodehh (1 commits)")

---

Tags

phpqrcodeqrcodeendroid

### Embed Badge

![Health badge](/badges/racinepilote-qr-code/health.svg)

```
[![Health](https://phpackages.com/badges/racinepilote-qr-code/health.svg)](https://phpackages.com/packages/racinepilote-qr-code)
```

###  Alternatives

[endroid/qr-code

Endroid QR Code

4.8k67.6M348](/packages/endroid-qr-code)[amirezaeb/heroqr

A Powerful QR Code Management Library For PHP

9510.3k](/packages/amirezaeb-heroqr)[arcanedev/qr-code

QR Code generator

1231.9k1](/packages/arcanedev-qr-code)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

295.1k](/packages/linkxtr-laravel-qrcode)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
