Hello Friends,
Today we will talk about laravel barcode generator. will see how to use barcode in laravel. we will see with the examples.
We will use picqer/php-barcode-generator laravel package.
picqer/php-barcode-generator is a composer package for generate barcode in your laravel application. you can simply generate svg, png, jpg and html image of barcode.
Also Read:- How to install laravel telescope
Install picqer/php-barcode-generator Package
composer require picqer/php-barcode-generator
Now you can use simply on your laravel blade page like this.
Also Read:- How to use Eloquent firstOrCreate in laravel
<!DOCTYPE html>
<html>
<head>
<title>How to Generate Bar Code in Laravel?</title>
</head>
<body>
<h1>How to Generate Bar Code in Laravel?</h1>
<h3>Product: 0001245259636</h3>
@php
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
@endphp
{!! $generator->getBarcode('0001245259636', $generator::TYPE_CODE_128) !!}
<h3>Product 2: 000005263635</h3>
@php
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
@endphp
<img src="data:image/png;base64,{{ base64_encode($generatorPNG->getBarcode('000005263635', $generatorPNG::TYPE_CODE_128)) }}">
</body>
</html>
Also Read:- How To Create 404 Error Page In Laravel
I hope it will help you…