Giter Site home page Giter Site logo

lavarel-barcode's Introduction

Build Status

Total Downloads

Latest Stable Version

License

Description

In this respository i will share you how to generate barcode using laravel 8. If you want just clone this repository do : git clone https://github.com/isaacwrk/lavarel-barcode , run the composer update in your terminal and after that, configure your .env file with your local database.

Requirements

  • Laravel 8
  • Composer

Preparing the environment

Configure Barcode Generator Package Update your project to receive the barcode with composer to install the milon/barcode

composer require milon/barcode

We will configure the milon/barcode package in laravel 8 app. So, Open theconfig/app.php file and register the provider and aliases for milon/barcode and paste the bellow code.

 'providers' =>  [

....

Milon\Barcode\BarcodeServiceProvider::class,

],

'aliases' =>  [

....

'DNS1D' => Milon\Barcode\Facades\DNS1DFacade::class,

'DNS2D' => Milon\Barcode\Facades\DNS2DFacade::class,

]

Creating Routes

 Route::get('barcode',[BarcodeGeneratorController::class,'index'])->name('barcode');
 Route::get('barcode-img',[BarcodeGeneratorController::class,'imgbarcode'])->name('barcode-img');

Controller Settings

<?php

  

namespace  App\Http\Controllers;

  

use  Illuminate\Http\Request;

  

class  BarcodeGeneratorController  extends  Controller

{

/**

* Write code on Method

*

* @return  response()

*/

public  function  index()

{

return  view('barcode');

}

/**

* image generate barcode

*

* @return  response()

*/

public  function  imgbarcode()

{

return  view('img-barcode');

}

}

Applying into blade

<h3  class="">Laravel 8 Barcode Generator Example</h3>

<!-- 1D Barcode Example -->

<div>{!! DNS1D::getBarcodeHTML('0987654321', 'C39') !!}</div><br>

<div>{!! DNS1D::getBarcodeHTML('7600322437', 'POSTNET') !!}</div></br>

<div>{!! DNS1D::getBarcodeHTML('8780395141', 'PHARMA') !!}</div></br>

<!-- 2D Barcode Example -->

<div>{!! DNS2D::getBarcodeHTML('https://www.github.com/isaacwrk', 'QRCODE') !!}</div><br><br>

<div>{!! DNS2D::getBarcodeSVG('https://www.github.com/isaacwrk', 'DATAMATRIX') !!}</div>

<br>

<br>

<h3  class="mb-4">Laravel 8 Barcode Generator Example Colorful example!</h3>

<!-- Get PNG Format Example -->

<img  src="data:image/png;base64,{{DNS1D::getBarcodePNG('github.com/isaacwrk', 'C39+',1,33,array(0,0,255), true)}}"  alt="barcode" /><br/><br/>

<img  src="data:image/png;base64,{{DNS1D::getBarcodePNG('1234567890', 'C39+',3,33,array(58, 247, 44), true)}}"  alt="barcode" /><br/><br/>

<img  src="data:image/png;base64,{{DNS1D::getBarcodePNG('Testando codigo de barras', 'C39+',1,33,array(255, 0, 0), true)}}"  alt="barcode" />

And now we have everything to test our barcode, so run

php artisan serve

by default, laravel uses port 8000 so you can test your routes created there!

localhost:8000/barcode

And this is the expected result!

lavarel-barcode's People

Contributors

isaacwrk avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.