PHPackages                             binarytec/barcodegen - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. binarytec/barcodegen

ActiveLibrary[Image &amp; Media](/categories/media)

binarytec/barcodegen
====================

Generates barcodes images as PNG or DATA-URL

0181PHP

Since Jun 10Pushed 3y agoCompare

[ Source](https://github.com/binarytec/barcodegen)[ Packagist](https://packagist.org/packages/binarytec/barcodegen)[ RSS](/packages/binarytec-barcodegen/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Barcode Generator
=================

[](#barcode-generator)

[![Author](https://camo.githubusercontent.com/fe82a7c2e80380a121ff03bdbd6554071cb9a52f6a4390e4fece711129c874c8/68747470733a2f2f7365637572652e67726176617461722e636f6d2f6176617461722f30373436313865333766363430643133643430323833306636313039326430393f643d6964656e7469636f6e26733d3530)](https://twitter.com/raffwpp)

Barcode Generator is a simple library that helps you create barcodes images. It's designed for Laravel 5 and it can create PNG images or DATA-URL strings. Based on great [php-generator](https://github.com/davidscotttufts/php-barcode)by [David Tufts](https://github.com/davidscotttufts)

Installation
============

[](#installation)

Through Composer, obviously:

```
composer require picoprime/barcodegen

```

or you can edit composer.json file and add `"picoprime/barcodegen": "~1.0"` to your "require" section.

Setup
=====

[](#setup)

Successfully tested in Laravel 5. Steps to make it work:

- edit "require" section in composer.json as described above
- **Ignore this step on Laravel 5.5 or newer - package will be auto discovered**edit config/app.php file and add `PicoPrime\BarcodeGen\BarcodeGenServiceProvider::class,`to providers
- create controller or add new methods to existing controllers (example is in "docs" folder). You can use `PicoPrime\BarcodeGen\BarcodeGenerator` class directly or `PicoPrime\BarcodeGen\BarcodeGen` facade. `BarcodeGenerator` can be injected as well. Before you call `generate()` method you have to pass variables to `init()` like so:

```
$this->barcode
    ->init($text, $size, $orientation, $codeType, $scale)
    ->generate()

```

or

```
$this->barcode
    ->generate($text, $size, $orientation, $codeType, $scale)

```

where:

- "text" is the text that you want to transform into barcode,
- "size" is barcode's height in pixels. If you need to change width as well then use "scale" together with "size"!
- "orientation" does what it says - changes barcode's orientation. Available: horizontal and vertical,
- "codeType" is the type of code that you want to generate. Available: code128, code128a, code39, code25, codabar.
- "scale" - if you need wider or just bigger barcode enter a number: 1 - default, 2 - 2x bigger, 2.5, ...

You can also pass these parameters as assoc or numeric array, like so:

```
$this->barcode
    ->generate(compact('text', 'size', 'orientation', 'codeType', 'scale'))

```

or using facade:

```
\PicoPrime\BarcodeGen\BarcodeGen::generate(['textToTransform', 50, 'horizontal', 'code128', 1])

```

Last step to generate image is to send whatever has been generated above to `->response('png')` or `->encode('data-url')`. Response will create Laravel's response and will display an image, whilst "encode" will create a string.

Please take a look at example controller in `docs` folder.

### Routes

[](#routes)

You can create routes as you like. Two examples that we usually use:

```
Route::get('barcode/img/{text}/{size?}/{scale?}/{codeType?}/{orientation?}', 'BarcodeController@barcodeAsPng');
Route::get('barcode/url/{text}/{size?}/{scale?}/{codeType?}/{orientation?}', 'BarcodeController@barcodeAsDataUrl');

```

Please take a look at example route in `docs` folder.

### Frontend use

[](#frontend-use)

Finally to use it in frontend, just use your route in `img` "src" attribute:

```

```

This example should generate horizontal, 50px, code128 barcode for "someText".

Issues
------

[](#issues)

Please feel free to create an issue on GitHub if you come across any errors or if you have an idea for improvement.

Enjoy
=====

[](#enjoy)

Oh and if you've come down this far, you might as well follow me on [twitter](https://twitter.com/raffwpp)or check out my [company's website](https://picoprime.com).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f309b4ab8f9b51eabed74fbcfecabd8a0dae88aaabd9680f3208d0c3f4e7ac8?d=identicon)[binarytecgmbh](/maintainers/binarytecgmbh)

---

Top Contributors

[![schruptor](https://avatars.githubusercontent.com/u/11615781?v=4)](https://github.com/schruptor "schruptor (2 commits)")

### Embed Badge

![Health badge](/badges/binarytec-barcodegen/health.svg)

```
[![Health](https://phpackages.com/badges/binarytec-barcodegen/health.svg)](https://phpackages.com/packages/binarytec-barcodegen)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
