01
AugThis package includes a Barcode generator written in PHP for encoding and rendering most common barcode formats to multiple image output formats.
You can install the package via composer:
composer require antwerpes/barcodes-1d
Use the Barcodes
factory class to create an encoder and render its output to SVG or a base64-encoded image:
use Antwerpes\Barcodes\Barcodes;
use Antwerpes\Barcodes\Enumerators\Format;
// SVG
$svg = Barcodes::create('12345678', Format::CODE_128);
file_put_contents('img.svg', $svg);
// Or as an image
$image = Barcodes::create('12345678', Format::CODE_128, 'png');
file_put_contents('img.png', base64_decode($image));
// Example for scaled up (4x) WEBP
$image = Barcodes::create('12345678', Format::CODE_128, 'webp', [
'image_scale' => 4,
]);
file_put_contents('img.webp', base64_decode($image));
Code 128
Barcodes::create('A12345', Format::CODE_128);
EAN-13
Barcodes::create('5901234123457', Format::EAN_13);
Barcodes::create('5901234123457', Format::EAN_13, 'svg', ['flat' => true]);
Barcodes::create('5901234123457', Format::EAN_13, 'svg', ['with_quiet_zone' => true]);
EAN-2 / EAN-5 / EAN-8
Barcodes::create('53', Format::EAN_2);
Barcodes::create('52495', Format::EAN_5);
Barcodes::create('96385074', Format::EAN_8);
UPC-A / UPC-E
Barcodes::create('123456789999', Format::UPC_A);
Barcodes::create('01245714', Format::UPC_E);
// These also work and will produce the same result
Barcodes::create('124571', Format::UPC_E);
Barcodes::create('01210000457', Format::UPC_E);
Barcodes::create('012100004574', Format::UPC_E);
Codabar
Barcodes::create('A12345B', Format::CODABAR);
Code 11
Barcodes::create('01234-5678', Format::CODE_11);
This package has a lot of options and code examples. If you want to learn more, then please visit Github
Published at : 01-08-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project