Laravel 8 Barcode Generator Example
In this example, i will show you laravel 8 barcode generator example. i would like to show you how to generate barcode in laravel 8. This post will give you simple example of how to save generated bar code in laravel. this example will help you laravel 8 barcode tutorial.
picqer/php-barcode-generator is a composer package for generate barcode in your laravel 8 application. you can simply generate svg, png, jpg and html image of barcode.
Here, i write example step by step to generate bar code in your laravel 8 admin panel. so let's follow few steps to get this example:
Preview:
Step 1: Install Laravel 8
In first step, If you haven't installed laravel 8 in your system then you can run bellow command and get fresh Laravel project.
composer create-project --prefer-dist laravel/laravel blog
Step 2: Install picqer/php-barcode-generator Package
Now we require to install picqer/php-barcode-generator package for barcode generator, that way we can use it's method. So Open your terminal and run bellow command.
composer require picqer/php-barcode-generator
Step 3: Create Route
In this step, we will create one route for testing example. So, let's add new route on that file.
routes/web.php
<?php
Route::view('barcode', 'barcode');
Step 4: Create Blade file
now we need to create barcode.blade.php for display bar code. so let's create blade file as like bellow code:
resources/views/barcode.blade.php
<!DOCTYPE html>
<html>
<head>
<title>How to Generate Bar Code in Laravel? - ItSolutionStuff.com</title>
</head>
<body>
<h1>How to Generate Bar Code in Laravel? - ItSolutionStuff.com</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>
Now you can run and check it.
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to use Model Events in Laravel 8?
- Laravel 8 Multiple Database Connection Example
- How to Get Last Executed Query in Laravel 8?
- Laravel 8 Autocomplete Search from Database Example
- Laravel 8 Clear Cache of Route, View, Config Command Example
- Laravel 8 Resource Route and Controller Tutorial Example
- Laravel 8 Change Date Format Examples
- Laravel 8 Send Mail using Queue Example
- Laravel 8 Guzzle Http Client Request Example
- Laravel 8 Livewire CRUD with Jetstream & Tailwind CSS
- Laravel 8/7 Custom Middleware Example
- Laravel 8 PayPal Integration Tutorial