tc-lib-barcode

May 1, 2026 ยท View on GitHub

PHP library for generating linear and 2D barcodes.

Latest Stable Version Build Coverage License Downloads

Sponsor on GitHub

If this project is useful to you, please consider supporting development via GitHub Sponsors.


Overview

tc-lib-barcode is a pure-PHP barcode generation library with broad support for industrial, retail, logistics, and document automation use cases.

It focuses on deterministic output and specification-driven encoding, making it suitable for labels, tickets, warehouse flows, and compliance documents. The API is structured so applications can generate barcode data once and render it as vectors or raster images depending on their output target.

Namespace\Com\Tecnick\Barcode
AuthorNicola Asuni info@tecnick.com
LicenseGNU LGPL v3 - see LICENSE
API docshttps://tcpdf.org/docs/srcdoc/tc-lib-barcode
Packagisthttps://packagist.org/packages/tecnickcom/tc-lib-barcode

Supported Formats

Linear

FormatDescription
C39CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9
C39+CODE 39 with checksum
C39ECODE 39 EXTENDED
C39E+CODE 39 EXTENDED + CHECKSUM
C93CODE 93 - USS-93
S25Standard 2 of 5
S25+Standard 2 of 5 + CHECKSUM
I25Interleaved 2 of 5
I25+Interleaved 2 of 5 + CHECKSUM
C128CODE 128
C128ACODE 128 A
C128BCODE 128 B
C128CCODE 128 C
EAN22-Digits UPC-Based Extension
EAN55-Digits UPC-Based Extension
EAN8EAN 8
EAN13EAN 13
UPCAUPC-A
UPCEUPC-E
MSIMSI (Variation of Plessey code)
MSI+MSI + CHECKSUM (modulo 11)
CODABARCODABAR
CODE11CODE 11
PHARMAPHARMACODE
PHARMA2TPHARMACODE TWO-TRACKS

2D

FormatDescription
AZTECAZTEC Code (ISO/IEC 24778:2008)
DATAMATRIXDATAMATRIX (ISO/IEC 16022)
PDF417PDF417 (ISO/IEC 15438:2006)
QRCODEQR-CODE
RAW2D RAW MODE comma-separated rows
RAW22D RAW MODE rows enclosed in square parentheses

Postal

FormatDescription
POSTNETPOSTNET
PLANETPLANET
RMS4CCRMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code)
KIXKIX (Klant index - Customer index)
IMBIMB - Intelligent Mail Barcode - Onecode - USPS-B-3200
IMBPREIMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 - pre-processed

Rendering

  • HTML output for web previews
  • Image-based rendering for downstream processing
  • Configurable dimensions, padding, and color

Output Formats

  • PNG Image
  • SVG Image
  • HTML DIV
  • Unicode String
  • Binary String

Requirements

  • PHP 8.1 or later
  • Extensions: bcmath, date, gd, pcre
  • Composer

Installation

composer require tecnickcom/tc-lib-barcode

Quick Start

<?php

require_once __DIR__ . '/vendor/autoload.php';

$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
    'QRCODE,H',
    'https://tecnick.com',
    -4,
    -4,
    'black',
    [-2, -2, -2, -2]
)->setBackgroundColor('white');

echo $bobj->getHtmlDiv();

For more formats and rendering options, see the example/ directory.


Development

make deps
make help
make qa

Build artifacts and reports are generated in target/.


Packaging

make rpm
make deb

For system packages, bootstrap with:

require_once '/usr/share/php/Com/Tecnick/Barcode/autoload.php';

Contributing

Contributions are welcome. Please read CONTRIBUTING.md, CODE_OF_CONDUCT.md, and SECURITY.md before submitting a pull request.


Contact

Nicola Asuni - info@tecnick.com