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

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

yangyao/php-barcode
===================

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

0857PHP

Since Apr 3Pushed 7y ago1 watchersCompare

[ Source](https://github.com/yangyao/php-barcode)[ Packagist](https://packagist.org/packages/yangyao/php-barcode)[ RSS](/packages/yangyao-php-barcode/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Barcode Generator
=====================

[](#php-barcode-generator)

This repo is forked from , The only difference is the addition of labels,and it will keep up with the original repo in time.

This is an easy to use, non-bloated, framework independent, barcode generator in PHP.

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.*

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

[](#installation)

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

```
composer require yangyao/php-barcode

```

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

Usage
-----

[](#usage)

Initiate the barcode generator for the output you want, then call the -&gt;getBarcode() routine as many times as you want.

```
$generator = new Picqer\Barcode\BarcodeGeneratorHTML();
echo $generator->getBarcode('081231723897', $generator::TYPE_CODE_1282,80,[0,0,0],new \Picqer\Barcode\BarcodeLabel('081231723897'));
```

The -&gt;getBarcode() routine accepts the following:

- $code Data for the barcode
- $type Type of barcode, use the constants defined in the class
- $widthFactor Width is based on the length of the data, with this factor you can make the barcode bars wider than default
- $totalHeight The total height of the barcode
- $color Hex code of the foreground color
- $label for BarcodeLabel instance

The barcode label accpets the following:

- $text for the label text
- $textAlign for thr alignment for label text
- $fontSize for the label text
- $color for the label text
- $marginTop for the label text in pixel
- $marginBottom for the label text in pixel
- $marginLeft for the label text in pixel
- $marginRight for the label text in pixel

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

[](#image-types)

```
$generatorSVG = new Picqer\Barcode\BarcodeGeneratorSVG();
$generatorPNG = new Picqer\Barcode\BarcodeGeneratorPNG();
$generatorJPG = new Picqer\Barcode\BarcodeGeneratorJPG();
$generatorHTML = new Picqer\Barcode\BarcodeGeneratorHTML();
```

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

[](#accepted-types)

- TYPE\_CODE\_39
- TYPE\_CODE\_39\_CHECKSUM
- TYPE\_CODE\_39E
- TYPE\_CODE\_39E\_CHECKSUM
- TYPE\_CODE\_93
- TYPE\_STANDARD\_2\_5
- TYPE\_STANDARD\_2\_5\_CHECKSUM
- TYPE\_INTERLEAVED\_2\_5
- TYPE\_INTERLEAVED\_2\_5\_CHECKSUM
- TYPE\_CODE\_128
- TYPE\_CODE\_128\_A
- TYPE\_CODE\_128\_B
- TYPE\_CODE\_128\_C
- TYPE\_EAN\_2
- TYPE\_EAN\_5
- TYPE\_EAN\_8
- TYPE\_EAN\_13
- TYPE\_UPC\_A
- TYPE\_UPC\_E
- TYPE\_MSI
- TYPE\_MSI\_CHECKSUM
- TYPE\_POSTNET
- TYPE\_PLANET
- TYPE\_RMS4CC
- TYPE\_KIX
- TYPE\_IMB
- TYPE\_CODABAR
- TYPE\_CODE\_11
- TYPE\_PHARMA\_CODE
- TYPE\_PHARMA\_CODE\_TWO\_TRACKS

Examples
--------

[](#examples)

Embedded PNG image in HTML:

```
$generator = new \Picqer\Barcode\BarcodeGeneratorPNG();
echo '';
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 78.1% 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/efd85b2f3a01cf8b5461e6855b27ce69b018fb1467ab3ae109fe169dd53b15fb?d=identicon)[yangyao](/maintainers/yangyao)

---

Top Contributors

[![casperbakker](https://avatars.githubusercontent.com/u/886975?v=4)](https://github.com/casperbakker "casperbakker (25 commits)")[![binarix](https://avatars.githubusercontent.com/u/4037156?v=4)](https://github.com/binarix "binarix (1 commits)")[![curtisgibby](https://avatars.githubusercontent.com/u/1086964?v=4)](https://github.com/curtisgibby "curtisgibby (1 commits)")[![frankirox](https://avatars.githubusercontent.com/u/1335554?v=4)](https://github.com/frankirox "frankirox (1 commits)")[![Keinbockwurst](https://avatars.githubusercontent.com/u/2493234?v=4)](https://github.com/Keinbockwurst "Keinbockwurst (1 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (1 commits)")[![amenk](https://avatars.githubusercontent.com/u/1087128?v=4)](https://github.com/amenk "amenk (1 commits)")[![stephangroen](https://avatars.githubusercontent.com/u/1607643?v=4)](https://github.com/stephangroen "stephangroen (1 commits)")

### Embed Badge

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

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

###  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)
