DEV Community

Cover image for Barcode generate using Laravel Framework!
Laravel Article
Laravel Article

Posted on • Edited on

3 1

Barcode generate using Laravel Framework!

Now a days, adding Barcode system in web application is most asking feature. Manually inputting products id for making invoice or finding products is really time consuming and have a chance to make mistake.

In this situation, Barcode system makes workflow faster and error free! In Laravel it is quit easy to implement barcode system. Even you don't need any physical barcode reader machine! yah, It's true!

Topics

  • Generate Barcode
  • Scanning barcode without physical barcode scanner!

Generate Barcode

Let's generate barcode first. To do that, add milon/barcode package first.

composer require milon/barcode
Enter fullscreen mode Exit fullscreen mode

Suppose, we have products ID like P-10001, P-10002, P-10003 and so on. To generate custom database ID like this, you can use Laravel ID generator.

Controller code

public function barcode(Request $request){
  $product = Product::find($request->get('id'));
  return view('barcode',compact('product'));
}
Enter fullscreen mode Exit fullscreen mode

View code

<div class="barcode">
    <p>{{$product->name}}</p>
    <p>Price: {{$product->sale_price}}</p>
    {!! DNS1D::getBarcodeHTML($product->id, "C128",1.4,22) !!}
    <p>{{$product->id}}</p>
</div>
Enter fullscreen mode Exit fullscreen mode

barcode
Note: Style the barcode css class according to your need. Please keep in mind most commonly used barcode sticker for printing barcode is 100x150mm

Scanning barcode without physical scanner!

After generating barcode basically we need a real physical barcode scanner for scanning barcode from product sticker and feed the code into our application but there is a free solution where you don't need physical barcode reader!

Barcode Client Server is a free barcode reader android application which can read barcode and send it to your PC. It's free and there is no scan limit!

How the Barcode Client Server works

Now when you scan any barcode by android app, it'll send scanned code to your PC immediately 👌

Neon image

Build better on Postgres with AI-Assisted Development Practices

Compare top AI coding tools like Cursor and Windsurf with Neon's database integration. Generate synthetic data and manage databases with natural language.

Read more →

Top comments (0)

Image of Stellar post

Check out Episode 1: How a Hackathon Project Became a Web3 Startup 🚀

Ever wondered what it takes to build a web3 startup from scratch? In the Stellar Dev Diaries series, we follow the journey of a team of developers building on the Stellar Network as they go from hackathon win to getting funded and launching on mainnet.

Read more

👋 Kindness is contagious

If this article connected with you, consider tapping ❤️ or leaving a brief comment to share your thoughts!

Okay