Home Laravel How to Generate BarCode in Laravel?

How to Generate BarCode in Laravel?

by Shahriar Sagor

Hi Devs,
In this tutorial, i will try to learn you laravel barcode generator example. So i will use how to generate barcode in laravel. You will learn how to save generate bar code in laravel. So you can learn laravel barcode tutorial. Here, i will Creating a basic example of picqer/php-barcode-generator laravel php.

So you can easily generate any barcode by using laravel 5, laravel 6, laravel 7 and laravel 8 any version easily.

picqer/php-barcode-generator is a very composer package for generate barcode in our laravel 8 application. I can simply generate any svg, png, jpg and html image of barcode.

Here, i write example step by step to generate bar code in our laravel admin panel. so let’s follow few steps to get this:

Step 1: Install Laravel

In first step, If you need to installed laravel in your systemby run bellow command and get fresh Laravel project.

composer create-project --prefer-dist laravel/laravel blog

Read Also : How to Autocomplete Textbox in Laravel 8 with Ajax?

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

Now we require to install a package. picqer/php-barcode-generator package is best for barcode generator, that way we can use it’s method. So now Open your terminal and run bellow command.

composer require picqer/php-barcode-generator

Step 3: Create Route

Now In this step, i will create one route for testing our example. So, let’s add new route on that file.

Read Also : How to Convert String Date to Date Format in PHP?



Route::view('barcode', 'barcode');

Step 4: Create Blade file

now i need to create barcode.blade.php for display bar code output. so let’s create blade file as like bellow code:

Read Also: Angularjs PHP MySQL Pagination Example


<!DOCTYPE html>
    <title>How to Generate Bar Code in Laravel? - codingspoint.com</title>
<h1>How to Generate Bar Code in Laravel? - codingspoint.com</h1>
<h3>Product: 0001245259342636</h3>
    $generator = new Picqer\Barcode\BarcodeGeneratorHTML();
{!! $generator->getBarcode('0001245259342636', $generator::TYPE_CODE_128) !!}
<h3>Product 2: 0001245259342636</h3>
    $generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
<img src="data:image/png;base64,{{ base64_encode($generatorPNG->getBarcode('0001245259342636', $generatorPNG::TYPE_CODE_128)) }}">

Now you can run and check it.

Read Also : PHP AngularJS CRUD with Search and Pagination Example From Scratch

thank you for read .I hope it can help you.Also you can follow us on Facebook.


You may also like