PHPackages                             brewerwall/php-barcode-generator - 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. brewerwall/php-barcode-generator

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

brewerwall/php-barcode-generator
================================

An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.

1.0.0(6y ago)011.2k↓52.6%1[8 issues](https://github.com/brewerwall/php-barcode-generator/issues)[1 PRs](https://github.com/brewerwall/php-barcode-generator/pulls)LGPL-3.0-onlyPHPPHP &gt;=7.1.0CI failing

Since Sep 20Pushed 6y agoCompare

[ Source](https://github.com/brewerwall/php-barcode-generator)[ Packagist](https://packagist.org/packages/brewerwall/php-barcode-generator)[ Docs](http://github.com/brewerwall/php-barcode-generator)[ RSS](/packages/brewerwall-php-barcode-generator/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

[![](https://user-images.githubusercontent.com/632330/57006043-fb823800-6ba2-11e9-8fa9-eba94b8011b5.png)](https://user-images.githubusercontent.com/632330/57006043-fb823800-6ba2-11e9-8fa9-eba94b8011b5.png) PHP Barcode Generator
[![Build Status](https://camo.githubusercontent.com/db87425984fd18be05f8c6f12ac13f8721f45513c64d6b40b45516ed57e9cd77/68747470733a2f2f7472617669732d63692e6f72672f62726577657277616c6c2f7068702d626172636f64652d67656e657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/brewerwall/php-barcode-generator) [![Codacy Badge](https://camo.githubusercontent.com/2ad925f194fa1726bba164ffd504e96ff7c1c1aabb49423b3322d50d4e11fbaa/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3736373131396538353464373434336238376133376562633933363937613432)](https://www.codacy.com/manual/Brewerwall/php-barcode-generator?utm_source=github.com&utm_medium=referral&utm_content=brewerwall/php-barcode-generator&utm_campaign=Badge_Grade)
=================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#--php-barcode-generator-)

This is an easy to use, non-bloated, framework independent, barcode generator in PHP. This version has been updated to follow PSR-4 and work with PHP 7.1+.

It creates SVG, PNG, JPG and HTML images, from the most used 1D barcode standards.

*The codebase is largely from the [TCPDF barcode generator](https://github.com/tecnickcom/TCPDF) by Nicola Asuni. This code is therefor licensed under LGPLv3. It is still a bit of a mess, bit I will clean it in the future. I do not expect the interface of this class will change during the clean ups.*

*This codebase, also extending off of [TCPDF barcode generator](https://github.com/tecnickcom/TCPDF) is a mostly direct copy from [Picqer barcode generator](https://github.com/picqer/php-barcode-generator). Updated to be php 7.1+ compliant.*

Installation
------------

[](#installation)

Install through [composer](https://getcomposer.org/doc/00-intro.md):

```
composer require brewerwall/php-barcode-generator

```

If you want to generate PNG or JPG images, you need the GD library or Imagick installed on your system as well.

Using IMB Barcodes require `bcmath` extension to be installed as well.

Usage
-----

[](#usage)

Create a new barcode generator. This will declare the code, the type of barcode and what format the code will be rendered.

```
$generator = new BarcodeGenerator(BarcodeType::TYPE_CODE_128, BarcodeRender::RENDER_JPG);

// Generate our code
$generated = $generator->generate('012345678');

// Generates the same code with style updates
$generated = $generator->generate('012345678', 4, 50, '#FFCC33');
```

The `$generator->generate()` method accepts the following parameters:

- `$code` Barcode value we need to generate.
- `$widthFactor` (default: 2) Width is based on the length of the data, with this factor you can make the barcode bars wider than default
- `$totalHeight` (default: 30) The total height of the barcode
- `$color` (default: #000000) Hex code of the foreground color

Image types
-----------

[](#image-types)

```
use Brewerwall\Barcode\Constants\BarcodeRender;

BarcodeRender::RENDER_JPG
BarcodeRender::RENDER_PNG
BarcodeRender::RENDER_HTML
BarcodeRender::RENDER_SVG
```

Accepted types
--------------

[](#accepted-types)

```
use Brewerwall\Barcode\Constants\BarcodeType;

BarcodeType::TYPE_CODE_39
BarcodeType::TYPE_CODE_39_CHECKSUM
BarcodeType::TYPE_CODE_39E
BarcodeType::TYPE_CODE_39E_CHECKSUM
BarcodeType::TYPE_CODE_93
BarcodeType::TYPE_STANDARD_2_5
BarcodeType::TYPE_STANDARD_2_5_CHECKSUM
BarcodeType::TYPE_INTERLEAVED_2_5
BarcodeType::TYPE_INTERLEAVED_2_5_CHECKSUM
BarcodeType::TYPE_CODE_128
BarcodeType::TYPE_CODE_128_A
BarcodeType::TYPE_CODE_128_B
BarcodeType::TYPE_CODE_128_C
BarcodeType::TYPE_EAN_2
BarcodeType::TYPE_EAN_5
BarcodeType::TYPE_EAN_8
BarcodeType::TYPE_EAN_13
BarcodeType::TYPE_UPC_A
BarcodeType::TYPE_UPC_E
BarcodeType::TYPE_MSI
BarcodeType::TYPE_MSI_CHECKSUM
BarcodeType::TYPE_POSTNET
BarcodeType::TYPE_PLANET
BarcodeType::TYPE_RMS4CC
BarcodeType::TYPE_KIX
BarcodeType::TYPE_IMB
BarcodeType::TYPE_CODABAR
BarcodeType::TYPE_CODE_11
BarcodeType::TYPE_PHARMA_CODE
BarcodeType::TYPE_PHARMA_CODE_TWO_TRACKS
```

Examples
--------

[](#examples)

Embedded PNG image in HTML:

```
$generator = new BarcodeGenerator(BarcodeType::TYPE_CODE_128, BarcodeRender::RENDER_PNG);
echo '';
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2470d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ea2196b6325a23c4064113f6febe2041eb8e8c2e66365228f80cd1e082dce45?d=identicon)[griffithben](/maintainers/griffithben)

---

Top Contributors

[![griffithben](https://avatars.githubusercontent.com/u/632330?v=4)](https://github.com/griffithben "griffithben (37 commits)")

---

Tags

phphtmlsvgbarcodepngEAN13jpegeanbarcode generatorCODABARupcjpgPharmacode39Standard 2 of 5MSIPOSTNETKIXcode128Code93KIXCODECode11

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/brewerwall-php-barcode-generator/health.svg)

```
[![Health](https://phpackages.com/badges/brewerwall-php-barcode-generator/health.svg)](https://phpackages.com/packages/brewerwall-php-barcode-generator)
```

###  Alternatives

[picqer/php-barcode-generator

An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.

1.8k27.4M109](/packages/picqer-php-barcode-generator)[tecnickcom/tc-lib-barcode

PHP library to generate linear and bidimensional barcodes

2947.5M39](/packages/tecnickcom-tc-lib-barcode)[choowx/rasterize-svg

A PHP library for converting SVG to JPEG, PNG, and WEBP

2275.4k](/packages/choowx-rasterize-svg)

PHPackages © 2026

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