PHPackages                             hrvoj3e/endroid-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. hrvoj3e/endroid-qr-code

ActiveLibrary

hrvoj3e/endroid-qr-code
=======================

Endroid QR Code

3.9.6(5y ago)037MITPHP &gt;=7.2

Since Jul 26Pushed 5y agoCompare

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

READMEChangelogDependencies (7)Versions (103)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, PDF or in binary format.

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

[](#installation)

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

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

Basic usage
-----------

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

[](#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);
$qrCode->setMargin(10);

// Set advanced options
$qrCode->setWriterByName('png');
$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->setValidateResult(false);

// Round block sizes to improve readability and make the blocks sharper in pixel based outputs (like png).
// There are three approaches:
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_MARGIN); // The size of the qr code is shrinked, if necessary, but the size of the final image remains unchanged due to additional margin being added (default)
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_ENLARGE); // The size of the qr code and the final image is enlarged, if necessary
$qrCode->setRoundBlockSize(true, QrCode::ROUND_BLOCK_SIZE_MODE_SHRINK); // The size of the qr code and the final image is shrinked, if necessary

// Set additional writer options (SvgWriter example)
$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');

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

[![QR Code](https://camo.githubusercontent.com/28aff43edfec528e70dc39b746ee41a3c68ef5096d8f0dc883b77d19de23c558/68747470733a2f2f656e64726f69642e6e6c2f71722d636f64652f4c6966652532306973253230746f6f25323073686f7274253230746f253230626525323067656e65726174696e672532305152253230636f6465732e706e67)](https://camo.githubusercontent.com/28aff43edfec528e70dc39b746ee41a3c68ef5096d8f0dc883b77d19de23c558/68747470733a2f2f656e64726f69642e6e6c2f71722d636f64652f4c6966652532306973253230746f6f25323073686f7274253230746f253230626525323067656e65726174696e672532305152253230636f6465732e706e67)

### Encoding

[](#encoding)

You can pick one of these values for encoding:

`ISO-8859-1`, `ISO-8859-2`, `ISO-8859-3`, `ISO-8859-4`, `ISO-8859-5`, `ISO-8859-6`, `ISO-8859-7`, `ISO-8859-8`, `ISO-8859-9`, `ISO-8859-10`, `ISO-8859-11`, `ISO-8859-12`, `ISO-8859-13`, `ISO-8859-14`, `ISO-8859-15`, `ISO-8859-16`, `Shift_JIS`, `windows-1250`, `windows-1251`, `windows-1252`, `windows-1256`, `UTF-16BE`, `UTF-8`, `US-ASCII`, `GBK` `EUC-KR`

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. For exemple the ECI block for `UTF-8` is `000026` so the above exemple will produce : `\000026Life is too short to be generating QR codes`. To ensure a maximum compatibility you can use the `ISO-8859-1` encoding that is the default encoding used by barcode scanners.

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.

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.

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.)
- Generate QR codes quickly from anywhere via the factory service
- Generate QR codes directly by typing an URL like /qr-code/&lt;text&gt;.png?size=300
- 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

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 84.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 ~16 days

Total

100

Last Release

1990d ago

Major Versions

1.x-dev → 2.0.02017-04-17

2.5.0 → 3.0.02017-12-03

2.5.1 → 3.3.02018-08-17

PHP version history (5 changes)1.7.4PHP &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

### Community

Maintainers

![](https://www.gravatar.com/avatar/6df3eda9db632ba6a237ce384711a8c7f645282a33b3bd2f9c7fcde695098155?d=identicon)[hrvoj3e](/maintainers/hrvoj3e)

---

Top Contributors

[![endroid](https://avatars.githubusercontent.com/u/537253?v=4)](https://github.com/endroid "endroid (286 commits)")[![sprain](https://avatars.githubusercontent.com/u/260361?v=4)](https://github.com/sprain "sprain (8 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)")[![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)")[![JohannCOSTE](https://avatars.githubusercontent.com/u/19409426?v=4)](https://github.com/JohannCOSTE "JohannCOSTE (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)")[![marcosgdf](https://avatars.githubusercontent.com/u/168744?v=4)](https://github.com/marcosgdf "marcosgdf (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![rexmolo](https://avatars.githubusercontent.com/u/9864232?v=4)](https://github.com/rexmolo "rexmolo (1 commits)")[![rk](https://avatars.githubusercontent.com/u/58199?v=4)](https://github.com/rk "rk (1 commits)")[![skruppy](https://avatars.githubusercontent.com/u/1025575?v=4)](https://github.com/skruppy "skruppy (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)")[![stewartadam](https://avatars.githubusercontent.com/u/77808?v=4)](https://github.com/stewartadam "stewartadam (1 commits)")[![thijskh](https://avatars.githubusercontent.com/u/3808792?v=4)](https://github.com/thijskh "thijskh (1 commits)")[![travispaul](https://avatars.githubusercontent.com/u/2118993?v=4)](https://github.com/travispaul "travispaul (1 commits)")

---

Tags

phpqrcodeqrbundlecodeendroid

### Embed Badge

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

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

###  Alternatives

[endroid/qr-code

Endroid QR Code

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

Endroid QR Code Bundle

32110.6M17](/packages/endroid-qr-code-bundle)[amirezaeb/heroqr

A Powerful QR Code Management Library For PHP

9510.3k](/packages/amirezaeb-heroqr)[tuncaybahadir/quar

A simple QR Code generation tool for your projects with Laravel 10, 11, 12 versions, php 8.2, 8.3, 8.4 and 8.5

6966.5k4](/packages/tuncaybahadir-quar)[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)
