Barcode
Generate QR codes and PDF417 barcodes and render them to PNG or SVG. Raxos Barcode is a small library that wraps chillerlan/php-qrcode for QR encoding and ships its own PDF417 encoder. Both formats sit behind a single Barcode base class that exposes a consistent matrix plus its height and width, along with renderPng and renderSvg helpers.
Install it with Composer.
shell
composer require raxos/barcodeHighlights
BarcodeShared base class that encodes data into a matrix and renders PNG or SVG.QRCodeEncode data as a QR code with a configurable error correction level.PDF417Encode data as a PDF417 barcode with configurable columns and security level.PNGRendererRender a barcode matrix to PNG image bytes using the GD extension.Explore by category
- Creating barcodes: the
Barcodebase class and the two concrete formats,QRCodeandPDF417, including their construction options and theBarcodeFormatenum. - Rendering to PNG or SVG: how to turn an encoded barcode into an image with the
renderPngandrenderSvghelpers, and the underlyingPNGRendererandSVGRendererclasses.
Quick example
php
<?php
declare(strict_types=1);
use Raxos\Barcode\QRCode;
use Raxos\Barcode\Enum\QRCodeErrorCorrectionLevel;
$qr = new QRCode('https://bas.dev', QRCodeErrorCorrectionLevel::Q);
$png = $qr->renderPng(scale: 6, margin: 12);
header('Content-Type: image/png');
echo $png;This creates a QR code with a higher error correction level and renders it straight to PNG bytes.
Next steps
See installation for requirements, or use the sidebar to navigate this package.