A Symfony Barcode & QR Code Generator Bundle with Twig extension.
Supports PHP 8.2+ and Symfony 6.4 / 7.x / 8.x
- Support 3 two-dimensional (2D) and 30 one-dimensional (1D) Barcode types
- Three output formats: HTML, PNG and SVG
- Twig integration: use the
barcodefunction directly in your templates - No external dependencies for barcode generation
composer require yellowskies/qr-code-bundleThe bundle uses Symfony Flex and will be automatically configured.
Add to config/bundles.php:
return [
// ...
Skies\QRcodeBundle\SkiesQRcodeBundle::class => ['all' => true],
];| Option | Type | Required | Allowed values | Description |
|---|---|---|---|---|
| code | string | required | What you want to encode | |
| type | string | required | See types below | Type of barcode |
| format | string | required | html, svg, png | Output format |
| width | int | optional | Width of unit | |
| height | int | optional | Height of unit | |
| color | string/array | optional | HTML color / [R,G,B] | Barcode color |
Default width/height: 2D = 5x5, 1D = 2x30 Default color: html/svg = "black", png = [0, 0, 0]
{# HTML barcode #}
{{ barcode({code: 'Hello World', type: 'qrcode', format: 'html'}) }}
{# SVG with custom size and color #}
{{ barcode({code: 'Hello World', type: 'qrcode', format: 'svg', width: 10, height: 10, color: 'green'}) }}
{# PNG (base64 encoded) #}
<img src="data:image/png;base64,{{ barcode({code: 'Hello World', type: 'datamatrix', format: 'png'}) }}" />use Skies\QRcodeBundle\Generator\Generator;
class MyController extends AbstractController
{
public function index(Generator $generator): Response
{
$barcode = $generator->generate([
'code' => 'Hello World',
'type' => 'qrcode',
'format' => 'svg',
'width' => 10,
'height' => 10,
'color' => 'green',
]);
return new Response($barcode);
}
}use Skies\QRcodeBundle\Generator\Generator;
$generator = new Generator();
$barcode = $generator->generate([
'code' => 'Hello World',
'type' => 'qrcode',
'format' => 'html',
]);// HTML or SVG
file_put_contents('/tmp/barcode.svg', $barcode);
// PNG (decode base64 first)
file_put_contents('/tmp/barcode.png', base64_decode($barcode));| Type | Name | Example |
|---|---|---|
| qrcode | QR Code | ![]() |
| pdf417 | PDF417 | ![]() |
| datamatrix | Data Matrix | ![]() |
| Type | Name |
|---|---|
| c128 | Code 128 |
| c128a/b/c | Code 128 A/B/C |
| c39 | Code 39 |
| c39+ | Code 39 with check digit |
| c39e | Code 39 Extended |
| c39e+ | Code 39 Extended with check digit |
| c93 | Code 93 |
| ean8 | EAN-8 |
| ean13 | EAN-13 |
| upca | UPC-A |
| upce | UPC-E |
| i25 | Interleaved 2 of 5 |
| s25 | Standard 2 of 5 |
| msi | MSI |
| postnet | POSTNET |
| planet | PLANET |
| rms4cc | RMS4CC |
| kix | KIX-code |
| imb | Intelligent Mail |
| codabar | Codabar |
| code11 | Code 11 |
| pharma | Pharmacode |
| pharma2t | Pharmacode Two-Track |
- PHP 8.2+
- Symfony 6.4+ / 7.x / 8.x
- GD extension (for PNG output)
- bcmath extension (for Intelligent Mail barcodes)
If upgrading from version 1.x:
- Update your
composer.jsonto require"yellowskies/qr-code-bundle": "^2.0" - Ensure you're running PHP 8.2+ and Symfony 6.4+
- The Twig function now returns the barcode string instead of echoing it (no change needed in templates)
Apache-2.0


