How to Generate BarCode in Laravel?

Published on : April 26,2023
How to Generate BarCode in Laravel?

Generating barcodes in Laravel is a common requirement for many web applications, especially those that deal with product inventory and sales. Barcodes provide a quick and efficient way to identify products, track inventory, and process transactions. In this blog post, we'll explore how to generate barcodes in Laravel using the SimpleSoftwareIO/simple-qrcode package.

 

Step 1: Install the Simple-QRCode Package

 The first step in generating barcodes in Laravel is to install the Simple-QRCode package. Simple-QRCode is a PHP library that provides an easy way to generate QR codes and barcodes. To install the package, open your terminal and navigate to your Laravel project directory, then run the following command:

composer require simplesoftwareio/simple-qrcode

This will install the package and its dependencies.

 

Step 2: Generate Barcodes

 Once the package is installed, you can use it to generate barcodes in Laravel. To generate a barcode, you need to first import the QrCode facade. Open the controller where you want to generate the barcode and add the following code:

use SimpleSoftwareIO\QrCode\Facades\QrCode;

public function generateBarcode()
{
    $barcode = QrCode::size(500)->generate('My first barcode!');
    return view('barcode', ['barcode' => $barcode]);
}

In the code above, we're using the QrCode facade to generate a barcode with a size of 500 pixels and the text 'My first barcode!'. We're then passing the barcode to the 'barcode' view.

The size() method sets the size of the barcode in pixels. You can adjust this value to suit your requirements. The generate() method takes a string as input and generates a barcode from it.

 

Step 3: Display the Barcode

Finally, we need to display the barcode in our view. Create a new blade view called 'barcode.blade.php' and add the following code:

<img src="data:image/png;base64, {!! base64_encode($barcode) !!} ">

This will display the barcode image in the browser.

The base64_encode() function converts the binary barcode data into a base64-encoded string, which can be embedded in an image tag.

 

Customizing the Barcode

 You can customize the barcode by changing the text, size, color, and other properties. For example, to change the text of the barcode, modify the string passed to the generate() method. To change the size of the barcode, modify the value passed to the size() method. To change the color of the barcode, use the color() method.

$barcode = QrCode::size(500)
                ->backgroundColor(255, 255, 204)
                ->color(0, 0, 0)
                ->generate('My customized barcode!');

In the code above, we're setting the background color to a light yellow, the foreground color to black, and the text to 'My customized barcode!'.

You can also add logos or images to the barcode using the merge() method. The merge() method takes an image file path as input and merges it with the barcode. For example:

$barcode = QrCode::size(500)
                ->merge('path/to/logo.png', 0.5, true)
                ->generate('My barcode with logo!');

In the code above, we're merging the barcode with an image file located at 'path/to/logo.png'. The second parameter of the merge() method specifies the opacity of the logo (0.0 to 1.0), and the third parameter specifies whether to resize the logo to fit the barcode.

Categories : Laravel

Tags : Laravel Simple-QRCode generate barcode barcode customization

Abhay Dudhatra
Abhay Dudhatra
I am a full-stack developer who is passionate about creating innovative solutions that solve real-world problems. With expertise in technologies such as PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter, and Bootstrap, I love to share my knowledge and help others in the industry through writing tutorials and providing tips. Consistency and hard work are my mantras, and I constantly strive to improve my skills and stay up-to-date with the latest advancements in the field. As the owner of Open Code Solution, I am committed to providing high-quality services to my clients and helping them achieve their business objectives.


170 Comments

fenofibrate 160mg oral buy cheap fenofibrate cheap fenofibrate


cialis 40mg pills viagra tablet order sildenafil 100mg


buy ketotifen 1 mg generic doxepin 75mg brand tofranil 75mg tablet


mintop over the counter home remedies for ed erectile dysfunction buy ed pills without a prescription


buy precose generic acarbose 50mg ca order fulvicin 250 mg for sale


buy generic aspirin 75mg buy hydroquinone cream for sale purchase imiquad sale


meloset 3 mg pill order danocrine online cheap danazol 100mg


buy dydrogesterone dydrogesterone over the counter buy empagliflozin 25mg


buy etodolac 600 mg sale cost pletal 100 mg buy cilostazol 100 mg generic


purchase fludrocortisone online cheap fludrocortisone drug how to get loperamide without a prescription


order prasugrel 10 mg online dramamine 50 mg tablet buy tolterodine 2mg


brand mestinon buy rizatriptan 10mg generic order rizatriptan 5mg generic


order ferrous sulfate 100mg online cheap purchase actonel generic cheap sotalol 40 mg


buy latanoprost generic order xeloda pills oral exelon 3mg


order enalapril 10mg online buy doxazosin 1mg online cheap purchase duphalac generic


purchase premarin pills order dostinex 0.5mg online cheap cheap sildenafil tablets


omeprazole online buy singulair pills metoprolol 100mg pill


cialis 40mg drug cheap viagra without prescription sildenafil mail order


buy telmisartan 80mg pills purchase molnupiravir generic molnunat price


cenforce over the counter cheap cenforce 100mg buy generic chloroquine


generic modafinil 200mg phenergan us buy prednisone 5mg without prescription


buy accutane pills for sale buy zithromax pill azithromycin 500mg without prescription


cefdinir sale metformin cheap how to get lansoprazole without a prescription


buy azipro 500mg pill gabapentin 600mg drug neurontin 600mg brand


order lipitor 10mg online cheap order albuterol for sale norvasc ca


black jack card game free real money casino online where can i buy furosemide


online casino games buy ventolin buy ventolin 4mg for sale


buy cheap pantoprazole order lisinopril 10mg for sale buy pyridium 200 mg


best online casino for real money online slots ivermectin 12mg


play slots for real money united states how to get clavulanate without a prescription synthroid online buy


buy symmetrel 100 mg order atenolol 50mg online aczone 100mg pill


clomid 50mg oral clomid pills imuran brand


buy generic medrol methylprednisolone 16mg online brand triamcinolone 4mg


oral vardenafil vardenafil buy online order tizanidine sale


phenytoin cost purchase dilantin generic oxybutynin 2.5mg cost


buy aceon 4mg online cheap coversum canada buy allegra 180mg online cheap


lioresal pills buy baclofen 10mg sale buy generic toradol for sale


oral loratadine 10mg dapoxetine 30mg pill buy priligy pills


buy ozobax without a prescription cost ozobax toradol price


alendronate oral colcrys usa oral nitrofurantoin


order inderal 10mg generic how to buy nurofen clopidogrel online


nortriptyline 25mg usa nortriptyline price buy panadol 500mg without prescription


buy generic glimepiride misoprostol without prescription buy generic etoricoxib for sale


buy medex sale order paxil 10mg purchase maxolon online cheap


order orlistat 60mg generic buy xenical 60mg for sale diltiazem oral


buy famotidine pill generic losartan 25mg tacrolimus 5mg us


nexium over the counter nexium online buy topamax price


buy azelastine online avalide us irbesartan 150mg ca


sumatriptan usa imitrex 25mg pills buy dutasteride no prescription


zyloprim pills buy rosuvastatin sale buy cheap generic rosuvastatin


zantac pill celebrex for sale online celebrex price


buspar over the counter amiodarone canada cordarone online


flomax sale buy zocor 10mg pills zocor 20mg without prescription


buy generic domperidone purchase domperidone online buy sumycin paypal


buy generic aldactone online buy spironolactone 25mg pill buy proscar 5mg online


paper assistance online thesis writing purchase essays


fluconazole for sale buy generic acillin generic cipro


order aurogra 50mg for sale brand estrace 1mg order generic estrace


buy generic metronidazole 400mg buy trimethoprim pills for sale order keflex 250mg online


lamotrigine over the counter buy lamotrigine 200mg online cheap nemazole online buy


buy cleocin online cheap purchase erythromycin pill order generic fildena 50mg


order tamoxifen 20mg online budesonide tablet purchase rhinocort


tretinoin gel canada avanafil ca order avana 100mg generic


order ceftin 500mg generic methocarbamol 500mg cheap methocarbamol for sale online


order tadacip 10mg oral diclofenac 50mg order indomethacin 50mg pills


buy trazodone for sale where to buy clindamycin without a prescription buy cheap clindac a


buy aspirin generic order aspirin 75mg pill burton brunette


order lamisil without prescription buy terbinafine without a prescription no deposit casino


academic writers online slot games free play real poker online


best essay writing websites essay writer 5 per page cefixime 100mg canada


cost calcitriol 0.25 mg buy calcitriol sale buy tricor generic


order generic trimox anastrozole 1mg pills buy biaxin without prescription


acne medications list buy trileptal generic trileptal 300mg over the counter


catapres 0.1mg us tiotropium bromide 9 mcg cheap tiotropium bromide cost


alfuzosin 10 mg without prescription abbreviation for acid blockers heartburn medicines over the counter


minomycin for sale online buy ropinirole 1mg generic buy cheap requip


prescription sleeping pills online best online weight loss prescription buy weight loss injections online


femara 2.5mg brand buy aripiprazole online abilify 30mg tablet


nicotine replacement therapy chewing tobacco online doctor for pain medication where to buy pain medication online


provera 5mg cheap hydrochlorothiazide 25 mg pill order microzide generic


herpes suppressive medication side effects cost of inhalers without insurance lowest gli sugar for diabetics


periactin 4mg canada buy luvox 100mg online ketoconazole price


strongest natural antifungal how to quickly reduce hypertension temporarily lower blood pressure trick


purchase cymbalta without prescription order provigil 100mg sale modafinil usa


gastitis pain lifestyle advice bacterial infection in bladder women complicated vs uncomplicated uti


order generic phenergan stromectol 12mg cheap buy ivermectin 6 mg


birth control patch order online pills to make sperm stronger how to naturally last longer


over the counter heartburn tablets flower fart pills supplements to reduce flatulence


buy deltasone 40mg without prescription brand amoxil cost amoxil 500mg


order ursodiol 150mg online purchase bupropion online cetirizine 10mg price


azithromycin generic order zithromax 500mg online gabapentin 600mg usa


how to buy strattera where to buy atomoxetine without a prescription buy sertraline 50mg


lexapro 10mg ca lexapro 20mg canada order revia 50mg for sale


lasix 40mg for sale antihistamine drugs list buy albuterol without prescription


order ipratropium 100 mcg generic buy dexona without prescription brand zyvox 600mg


how to buy nateglinide atacand 16mg cheap atacand without prescription


purchase augmentin pill synthroid cost clomid generic


starlix generic captopril pills purchase atacand without prescription


order levitra 10mg plaquenil 200mg for sale order hydroxychloroquine 400mg generic


purchase carbamazepine sale buy generic tegretol online order lincocin 500mg generic


order cenforce 50mg generic order cenforce for sale purchase glucophage generic


duricef generic buy cheap epivir epivir order online


buy atorvastatin cheap lisinopril 2.5mg canada zestril us


prilosec brand buy metoprolol sale tenormin order online


cabergoline oral order dapoxetine 60mg generic dapoxetine 30mg us


buy methylprednisolone for sale buy desloratadine cheap generic clarinex 5mg


cytotec 200mcg tablet buy cheap generic misoprostol buy generic diltiazem over the counter


order piracetam buy generic clomipramine for sale anafranil medication


order acyclovir for sale zovirax price order crestor 10mg pill


sporanox 100mg oral sporanox without prescription tindamax 500mg ca


purchase ezetimibe without prescription purchase zetia pills tetracycline 500mg price


buy cheap generic zyprexa brand nebivolol 5mg diovan 80mg for sale


flexeril 15mg over the counter buy toradol paypal toradol order


buy gloperba pill buy colcrys 0.5mg generic buy methotrexate pill


medication to clear acne cheap benzac maximum strength acne medication


prescription only allergy medication where to buy albuterol without a prescription allergy over the counter drugs


nausea drugs list order duricef generic



prednisone 20mg usa cheap prednisone 10mg


heartburn tablets prescription how to buy avapro


prescribed acne medication names buy omnicef 300 mg pills acne medications list


best non prescription allergy medication albuterol pills allergy medication without side effects


medication thats makes you puke lincomycin over the counter


order accutane 40mg generic order isotretinoin 40mg for sale isotretinoin 20mg cheap


oral amoxicillin 1000mg amoxil 500mg cheap order amoxil 250mg without prescription


buy sleeping tablets online uk buy modafinil 100mg for sale


order generic zithromax buy cheap azithromycin zithromax price


buy gabapentin 100mg pills order neurontin sale


buy generic azipro for sale azithromycin 500mg over the counter buy azithromycin 500mg pill


buy lasix 40mg sale furosemide 40mg cheap


buy prednisolone sale omnacortil 40mg for sale cheap omnacortil 20mg


order amoxicillin 250mg online buy amoxicillin 500mg pill buy amoxicillin pills for sale


buy monodox pills buy doxycycline 200mg for sale


albuterol pills buy albuterol online order albuterol online


order augmentin 375mg generic buy clavulanate generic


order synthroid 75mcg without prescription buy synthroid 75mcg for sale levothyroxine over the counter


levitra 10mg oral levitra 10mg sale


purchase clomiphene pill generic clomiphene 100mg serophene online order


order tizanidine pill order tizanidine pill buy tizanidine generic


deltasone 5mg for sale buy generic prednisone 10mg order prednisone pill


rybelsus usa purchase rybelsus pills semaglutide order


order accutane 40mg without prescription buy accutane 10mg pills accutane 20mg brand


order generic semaglutide semaglutide 14mg generic buy semaglutide 14mg without prescription


order albuterol inhalator sale albuterol uk albuterol tablet


order amoxicillin 500mg online cheap amoxil online buy cheap amoxicillin for sale


augmentin cheap augmentin uk purchase augmentin pills


order azithromycin for sale buy zithromax paypal order azithromycin without prescription


generic omnacortil 10mg omnacortil generic buy generic prednisolone


parx casino online free slot games for fun online blackjack with friends


order generic vardenafil 10mg levitra over the counter levitra 10mg for sale


lyrica 75mg price buy lyrica generic order pregabalin 150mg pill


hydroxychloroquine 200mg cheap order hydroxychloroquine 200mg pills buy hydroxychloroquine medication


buy triamcinolone 10mg online order triamcinolone 10mg pills buy triamcinolone pills for sale


order tadalafil pills usa cialis sales price of cialis


order clarinex online cheap purchase clarinex pill order desloratadine 5mg online


purchase cenforce for sale cost cenforce 100mg where can i buy cenforce


buy claritin pills for sale claritin oral buy loratadine without a prescription


aralen where to buy chloroquine 250mg oral chloroquine 250mg brand


xenical over the counter order orlistat 120mg generic how to get diltiazem without a prescription


lipitor 80mg canada lipitor 20mg price how to get atorvastatin without a prescription


buy zovirax medication zovirax 800mg cost allopurinol tablet


oral amlodipine order norvasc 5mg pills buy amlodipine pills


order lisinopril 2.5mg sale zestril 5mg pill prinivil price


buy rosuvastatin 20mg pills order ezetimibe 10mg pills order zetia pill


buy omeprazole cheap buy omeprazole 20mg without prescription buy prilosec 20mg pills


how to buy motilium motilium cheap tetracycline 250mg usa


medication to stop heart attack buy lopressor 50mg without prescription order lopressor 100mg generic


buy generic cyclobenzaprine baclofen 25mg pill buy baclofen 10mg pill


atenolol 100mg over the counter order atenolol sale order atenolol online


order toradol 10mg pills colchicine 0.5mg pills purchase colchicine online cheap


Leave a comment

We'll never share your email with anyone else. Required fields are marked *

Related Articles