LaravelPackages.net
Acme Inc.
Toggle sidebar
max13/laravel-barcode

Laravel package to manage and generate barcodes

266
1
v0.3.2
About max13/laravel-barcode

max13/laravel-barcode is a Laravel package for laravel package to manage and generate barcodes. It currently has 1 GitHub stars and 266 downloads on Packagist (latest version v0.3.2). Install it with composer require max13/laravel-barcode. Discover more Laravel packages by max13 or browse all Laravel packages to compare alternatives.

Last updated

Laravel package to manage and create barcodes

Latest Version on Packagist GitHub Tests Action Status Total Downloads

With this package you can manage barcodes (external barcodes, checkings, etc…) or generate your own as long as you configure it correctly.

Installation

You can install the package via composer:

composer require max13/laravel-barcode

This package embeds corresponding fonts to write the barcode on a webpage. You will see how to use them in the Usage section below.

Configuration

Barcode types are available like so (defaults to ean13):

| type | has font | | --- | --- | | ean8 | yes | | ean13 | yes |

To change the barcode type used, set to your .env file: BARCODE_TYPE= with the barcode type you want to use.

When a barcode has a font and you would use it, you need to publish the package assets using:

php artisan vendor:publish --provider="Max13\Barcode\ServiceProvider" --tag=public

Don’t forget to include the css files in your layouts.

If you need to see or change this package config file, you can publish the config file using this command:

php artisan vendor:publish --provider="Max13\Barcode\ServiceProvider" --tag=config

This will export the config file to your app’s config folder.

Usage

// To check an ean13 barcode:
if (Barcode::isValid('0123456789104')) {
    // This barcode is valid
}

// To calculate an ean13 barcode check digit (the last digit)
echo Barcode::checksum('012345678910'); // Show: '4'

// To fix an ean13 barcode if it's needed
echo Barcode::fix('0123456789100'); // Show: '0123456789104'

And finally, if you need to write the barcode using the embedded font, you need to get the encoded form of the barcode (ex: in case of ean13, the font will be applied on html class f-ean13):

<span class="f-ean13">{{ Barcode::encode('0123456789104') }}</span>

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Comments