Showing posts with label laravel 9 barcode generator tutorial with example. Show all posts
Showing posts with label laravel 9 barcode generator tutorial with example. Show all posts

Laravel 9 Barcode Generator Tutorial

Laravel 9 Barcode Generator Tutorial
Hi dev, In this blog, I am explain laravel 9 barcode generator tutorial with example. We will use picqer/php-barcode-generator package for generating barcode in laravel 9 application. So i will use how to generate barcode in laravel 9. You will learn how to save generate bar code in laravel 9. i will Creating a basic example of picqer/php-barcode-generator laravel php. This is a picqer/php-barcode-generator is a very composer package for generate barcode in our laravel 9 app. I can simply generate any svg, png, jpg and html image of barcode. So you can easily generate any barcode by using laravel 5, laravel 6, laravel 7 , laravel 8 and laravel 9 any version easily. So let's start following example: Install Laravel 9 This is optional; however, if you have not created the laravel app, then you may go ahead and execute the below command:
composer create-project laravel/laravel laravel-barcode
Install picqer/php-barcode-generator In first step we will install picqer/php-barcode-generator Package that provides to generate Barcode in laravel application. So, first open your terminal and run bellow command:
composer require picqer/php-barcode-generator
1: Laravel Generate Barcode Example Here, we will create simple route for generating Barcode, Then i will show you output bellow as well: routes/web.php
<?php
  
use Illuminate\Support\Facades\Route;
  
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
  
Route::get('barcode', function () {
  
    $generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
    $image = $generatorPNG->getBarcode('000005263635', $generatorPNG::TYPE_CODE_128);
  
    return response($image)->header('Content-type','image/png');
});
Output:
2: Laravel Generate Barcode and Save Example Here, we will create simple route for generating Barcode: routes/web.php
<?php
  
use Illuminate\Support\Facades\Route;
  
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
  
Route::get('barcode-save', function () {
  
    $generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
    $image = $generatorPNG->getBarcode('000005263635', $generatorPNG::TYPE_CODE_128);
  
    Storage::put('barcodes/demo.png', $image);
  
    return response($image)->header('Content-type','image/png');
});
3: Laravel Generate Barcode with Blade Example Here, we will create simple route for generating Barcode, Then i will show you output bellow as well: routes/web.php
<?php
  
use Illuminate\Support\Facades\Route;
  
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
  
Route::get('barcode-blade', function () {
  
    $generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML();
    $barcode = $generatorHTML->getBarcode('0001245259636', $generatorHTML::TYPE_CODE_128);
  
    return view('barcode', compact('barcode'));
});
resources/views/barcode.blade.php
<!DOCTYPE html>
<html>
<head>
    <title>laravel 9 barcode generator tutorial with example - Itwebtuts</title>
</head>
<body>
    
    <h1>laravel 9 barcode generator tutorial with example - Itwebtuts</h1>
         
    <h3>Product: 1234567890</h3>  
    {!! $barcode !!}
  
</body>
</html>
I hope it can help you...