PHPackages                             antwerpes/barcodes-1d - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. antwerpes/barcodes-1d

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

antwerpes/barcodes-1d
=====================

Library for programmatically creating and rendering barcodes

1.5.0(1y ago)258.7k↓33.3%4[2 PRs](https://github.com/antwerpes/barcodes-1d/pulls)MITPHPPHP ^8.1CI passing

Since Jun 30Pushed 1y ago2 watchersCompare

[ Source](https://github.com/antwerpes/barcodes-1d)[ Packagist](https://packagist.org/packages/antwerpes/barcodes-1d)[ Docs](https://github.com/antwerpes/barcodes)[ RSS](/packages/antwerpes-barcodes-1d/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (10)Used By (0)

 [![Logo](./.art/logo.png)](./.art/logo.png)

 [![Packagist](https://camo.githubusercontent.com/9e19678fa6d079c1f99a4bafffb881adce1ca8ada937c7c25f0c5e11ae02d3a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616e747765727065732f626172636f6465732d31642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/antwerpes/barcodes-1d) [![Code Style](https://camo.githubusercontent.com/b90566cc0ce81bbed630d0880bfc8f29e2d658406a680fdd4e84567e38605007/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f616e747765727065732f626172636f6465732d31642f6c696e743f6c6162656c3d636f64652532307374796c65)](https://github.com/antwerpes/barcodes-1d/actions?query=workflow%3Alint+branch%3Amaster) [![Downloads](https://camo.githubusercontent.com/d432648f637de557129ff1afc01fbd3219f3378242cb68fd6db5a9a3738dfd3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e747765727065732f626172636f6465732d31642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/antwerpes/barcodes-1d) [![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/antwerpes/barcodes-1d/blob/master/LICENSE.md)

Barcodes 1D
===========

[](#barcodes-1d)

Barcode generator written in PHP for encoding and rendering most common barcode formats to multiple image output formats.

Features
--------

[](#features)

- Supports most common barcode formats (Code128, EAN, UPC, ...)
- Can render to SVG, PNG, JPG or WEBP using GD
- Images (PNG/JPG/WEBP) may be configured to scale up to any size
- Supports common customization requirements (size, color, text display, font size, background color, font for image rendering, or format-specific options such as guard bars or quiet zones)

Supported barcodes
------------------

[](#supported-barcodes)

FormatVariationsCode 128Auto-Mode and forced A/B/CEANEAN-2 / EAN-5 / EAN-8 / EAN-13UPCUPC-A / UPC-EMSIMod10, Mod11, Mod1010, Mod1110CodabarCode 11Code 2 of 5Code 2 of 5 InterleavedCode 39Code 93ITF-14PharmacodeInstallation
------------

[](#installation)

Install the package via composer:

```
composer require antwerpes/barcodes-1d
```

Usage
-----

[](#usage)

Use the `Barcodes` factory class to create an encoder and render its output to SVG or a base64-encoded image:

```
use Antwerpes\Barcodes\Barcodes;
use Antwerpes\Barcodes\Enumerators\Format;

// SVG
$svg = Barcodes::create('12345678', Format::CODE_128);
file_put_contents('img.svg', $svg);

// Or as an image
$image = Barcodes::create('12345678', Format::CODE_128, 'png');
file_put_contents('img.png', base64_decode($image));

// Example for scaled up (4x) WEBP
$image = Barcodes::create('12345678', Format::CODE_128, 'webp', [
    'image_scale' => 4,
]);
file_put_contents('img.webp', base64_decode($image));
```

### Customization

[](#customization)

Check out the [options](#options) for an overview of all customization options.

Examples
--------

[](#examples)

#### Code 128

[](#code-128)

[![Code 128](./.art/code128.svg)](./.art/code128.svg)

```
Barcodes::create('A12345', Format::CODE_128);
```

#### EAN-13

[](#ean-13)

[![EAN-13](./.art/ean13.svg)](./.art/ean13.svg) [![EAN-13 Flat](./.art/ean13-flat.svg)](./.art/ean13-flat.svg) [![EAN-13 Quiet Zone](./.art/ean13-quiet-zone.svg)](./.art/ean13-quiet-zone.svg)

```
Barcodes::create('5901234123457', Format::EAN_13);
Barcodes::create('5901234123457', Format::EAN_13, 'svg', ['flat' => true]);
Barcodes::create('5901234123457', Format::EAN_13, 'svg', ['with_quiet_zone' => true]);
```

#### EAN-2 / EAN-5 / EAN-8

[](#ean-2--ean-5--ean-8)

[![EAN-2](./.art/ean2.svg)](./.art/ean2.svg) [![EAN-5](./.art/ean5.svg)](./.art/ean5.svg) [![EAN-8](./.art/ean8.svg)](./.art/ean8.svg)

```
Barcodes::create('53', Format::EAN_2);
Barcodes::create('52495', Format::EAN_5);
Barcodes::create('96385074', Format::EAN_8);
```

#### UPC-A / UPC-E

[](#upc-a--upc-e)

[![UPC-A](./.art/upca.svg)](./.art/upca.svg) [![UPC-E](./.art/upce.svg)](./.art/upce.svg)

```
Barcodes::create('123456789999', Format::UPC_A);
Barcodes::create('01245714', Format::UPC_E);
// These also work and will produce the same result
Barcodes::create('124571', Format::UPC_E);
Barcodes::create('01210000457', Format::UPC_E);
Barcodes::create('012100004574', Format::UPC_E);
```

#### Codabar

[](#codabar)

[![Codabar](./.art/codabar.svg)](./.art/codabar.svg)

```
Barcodes::create('A12345B', Format::CODABAR);
```

#### Code 11

[](#code-11)

[![Code 11](./.art/code11.svg)](./.art/code11.svg)

```
Barcodes::create('01234-5678', Format::CODE_11);
```

#### Code 2 of 5 / Code 2 of 5 Interleaved / ITF-14

[](#code-2-of-5--code-2-of-5-interleaved--itf-14)

[![Code 25](./.art/code25.svg)](./.art/code25.svg) [![Code 25 Interleaved](./.art/code25i.svg)](./.art/code25i.svg) [![ITF-14](./.art/itf14.svg)](./.art/itf14.svg)

```
Barcodes::create('1234567', Format::CODE_25);
Barcodes::create('12345670', Format::CODE_25_INTERLEAVED);
Barcodes::create('98765432109213', Format::ITF_14);
```

#### Code 39 / Code 93

[](#code-39--code-93)

[![Code 39](./.art/code39.svg)](./.art/code39.svg) [![Code 93](./.art/code93.svg)](./.art/code93.svg)

```
Barcodes::create('AB12', Format::CODE_39);
Barcodes::create('TEST93', Format::CODE_93);
```

#### MSI

[](#msi)

[![MSI](./.art/msi.svg)](./.art/msi.svg)

```
Barcodes::create('8052', Format::MSI);
```

#### Pharmacode

[](#pharmacode)

[![MSI](./.art/pharmacode.svg)](./.art/pharmacode.svg)

```
Barcodes::create('1234', Format::PHARMACODE);
```

Options
-------

[](#options)

Generic options for all barcode formats:

OptionDefaultTypeComment`width``2``int`Width of a single bar`height``100``int`Height of a regular bar`text_margin``2``int`Distance between barcode and text`text_align``center``string``left` / `center` / `right``background``#ffffff``string|null`Background color. Use `null` for transparent background`color``#000000``string`Color of the barcode and text`text_color`–`string`Text color. Falls back to `color` if not set`margin``10``int`Margin on all sides of the barcode`margin_top`–`int`Falls back to `margin` if not set`margin_right`–`int`Falls back to `margin` if not set`margin_bottom`–`int`Falls back to `margin` if not set`margin_left`–`int`Falls back to `margin` if not set`display_value``true``bool`Should the code text be displayed below the barcode?`font_size``20``int`Large font sizes may break the layout`image_font``JetBrains Mono``string`Path to custom font TTF for image rendering (not used for SVG).`image_scale``1``int`Sets the final image scale, e.g. 2x or 4x (not used for SVG).There are additional options for some barcode formats:

**Code128**

OptionDefaultTypeComment`mode``AUTO``string`Encoding mode (`AUTO` / `A`/ `B`/ `C`). Use `AUTO` for most efficient encoding.**EAN-8 / EAN-13 / UPC-A / UPC-E**

OptionDefaultTypeComment`flat``false``bool`Flat encoding (without the guard bars)`with_quiet_zone``false``bool`Enables quiet zones with (`` symbols). Only relevant for EAN-8 / EAN-13**Code39**

OptionDefaultTypeComment`enable_checksum``false``bool`Calculate and append mod43 checksum`full_ascii``false``bool`Enable full ASCII mode**Code39**

OptionDefaultTypeComment`full_ascii``false``bool`Enable full ASCII mode**MSI**

OptionDefaultTypeComment`check_digit``null``string|null``MOD_10` / `MOD_11` / `MOD_1010` / `MOD_1110`Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Acknowledgements
----------------

[](#acknowledgements)

- [lindell/JsBarcode](https://github.com/lindell/JsBarcode)
- [barnhill/barcodelib](https://github.com/barnhill/barcodelib)

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance46

Moderate activity, may be stable

Popularity36

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 74.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.

###  Release Activity

Cadence

Every ~168 days

Recently: every ~245 days

Total

7

Last Release

406d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.3.0PHP ^8.1|^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/34a7cd6c6e8c5fd30b6cd28645c3384f343fc90d10b0df8c80c7ad424e3dba2a?d=identicon)[chiiya](/maintainers/chiiya)

---

Top Contributors

[![chiiya](https://avatars.githubusercontent.com/u/15029301?v=4)](https://github.com/chiiya "chiiya (43 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

barcodesEAN13upccode128antwerpes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antwerpes-barcodes-1d/health.svg)

```
[![Health](https://phpackages.com/badges/antwerpes-barcodes-1d/health.svg)](https://phpackages.com/packages/antwerpes-barcodes-1d)
```

###  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.8k25.5M88](/packages/picqer-php-barcode-generator)[php-soap/ext-soap-engine

An ext-soap engine implementation

443.2M7](/packages/php-soap-ext-soap-engine)[symfony/ux-cropperjs

Cropper.js integration for Symfony

19280.3k3](/packages/symfony-ux-cropperjs)[barcode-bakery/barcode-1d

Generates 1D barcodes from a PHP server to a file or HTML document.

10146.1k1](/packages/barcode-bakery-barcode-1d)[bitgrave/barcode-bundle

provide barcode rendering service into your Symfony2 application.

25444.0k1](/packages/bitgrave-barcode-bundle)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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