How To Generate Barcode In Laravel 8

Siddharth Shukla
1 min readMar 28, 2021

--

How To Generate Barcode In Laravel 8

Step 1: Create the application

We need to run a command to create Laravel 8 projects.

composer create-project --prefer-dist laravel/laravel laravel-8-barcode-generator

Step 2: Install picqer/php-barcode-generator Package

composer require picqer/php-barcode-generator

Step 3: Create Route

Now I am going to create a route for calling controller and function.

routes/web.php

<?phpRoute::view('barcode', 'barcode');

Step 4: Create Blade file

resources/views/barcode.blade.php

<!DOCTYPE html>
<html>
<head>
<title>Barcode Generator In Laravel 8 </title>
<!-- CSS only -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- Js only -->
</head>
<body>
<div class="container">
<div class="jumbotron">
<div class="container text-center">
<h2>
Barcode Generator In Laravel 8
</h2>
</div>
</div>
<div class="container text-center d-flex align-items-center justify-content-center">
<h3>Product 2: MAC-1200</h3>
@php
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
@endphp
<img src="data:image/png;base64,{{ base64_encode($generatorPNG->getBarcode('MAC-1200', $generatorPNG::TYPE_CODE_128)) }}">
</div>
</div>
</body>
</html>

Read More: https://realprogrammer.in/how-to-generate-barcode-in-laravel-8/

--

--

Siddharth Shukla

I'm a Full Stack Engineer based in India ☀️, working at Kreativ Street. I'm a coding passion focused on Python, specifically Laravel & Django.