PHPackages                             laikait/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. laikait/barcode-generator

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

laikait/barcode-generator
=========================

A lightweight PHP barcode generator library supporting multiple formats with SVG and PNG output.

v1.1.1(2mo ago)04MITPHPPHP &gt;=8.1

Since Mar 9Pushed 2mo agoCompare

[ Source](https://github.com/laikait/barcode-generator)[ Packagist](https://packagist.org/packages/laikait/barcode-generator)[ RSS](/packages/laikait-barcode-generator/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

Laika Barcode Generator
=======================

[](#laika-barcode-generator)

A lightweight PHP 8.1+ barcode generator library supporting 1D and 2D barcode formats with **SVG and PNG** output, watermarks, title/footer text, and file saving — zero runtime dependencies.

---

Supported Formats
-----------------

[](#supported-formats)

### 1D Barcodes — `Laika\Barcode\Barcode`

[](#1d-barcodes--laikabarcodebarcode)

KeyFormatInput`code128`Code 128Any printable ASCII`code39`Code 39A–Z, 0–9, `-` `.` ` ` `$ / + %``ean13`EAN-1312 or 13 digits`ean8`EAN-87 or 8 digits`upca`UPC-A11 or 12 digits### 2D Barcodes — `Laika\Barcode\QrCode`

[](#2d-barcodes--laikabarcodeqrcode)

FormatVersionsEC LevelsInputQR Code1–10L, M, Q, HAny bytes/UTF-8---

Requirements
------------

[](#requirements)

- PHP **8.1+**
- GD extension *(only for PNG output)*

---

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

[](#installation)

```
composer require laikait/barcode-generator
```

---

1D Barcodes
-----------

[](#1d-barcodes)

### Quick Start

[](#quick-start)

```
use Laika\Barcode\Barcode;

$svg = Barcode::type('code128')->data('Hello, World!')->svg();

header('Content-Type: image/svg+xml');
echo $svg;
```

### SVG

[](#svg)

```
$svg = Barcode::type('ean13')
    ->data('590123412345')   // 12 digits — check digit auto-computed
    ->svg();
```

### PNG *(requires GD)*

[](#png-requires-gd)

```
$png = Barcode::type('code128')->data('LAIKA-2025')->png();

header('Content-Type: image/png');
echo $png;
```

### Save to File

[](#save-to-file)

Format is inferred from the file extension (`.svg` or `.png`). Directories are created automatically.

```
$path = Barcode::type('code128')->data('ABC-123')->save('/var/www/barcodes/label.svg');
$path = Barcode::type('ean13')->data('590123412345')->save('/var/www/barcodes/product.png');
```

### Inline in HTML

[](#inline-in-html)

```
$svg = Barcode::type('ean8')->data('9638507')->svg();
echo '' . $svg . '';
```

### Use in HTML TAG

[](#use-in-html-tag)

```
$svg = Barcode::type('ean8')->data('9638507')->svgBase64();
$png = Barcode::type('ean8')->data('9638507')->pngBase64();
echo '
