PHPackages                             janisvepris/zpl-builder-php - 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. janisvepris/zpl-builder-php

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

janisvepris/zpl-builder-php
===========================

A simple PHP library for building ZPL (Zebra Programming Language) label payloads.

0.63.1(3d ago)12.5k↑94.2%MITPHPPHP ^8.3CI failing

Since Feb 9Pushed 3d agoCompare

[ Source](https://github.com/JanisVepris/zpl-builder-php)[ Packagist](https://packagist.org/packages/janisvepris/zpl-builder-php)[ RSS](/packages/janisvepris-zpl-builder-php/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (9)Dependencies (13)Versions (22)Used By (0)

[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/1abe6354b1f93296fc3ada0cbaabafeab117c236f7fd8b0f2527da84253ce36f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a616e69737665707269732f7a706c2d6275696c6465722d7068702f63692e796d6c3f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/1abe6354b1f93296fc3ada0cbaabafeab117c236f7fd8b0f2527da84253ce36f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6a616e69737665707269732f7a706c2d6275696c6465722d7068702f63692e796d6c3f7374796c653d666c61742d737175617265)[![codecov](https://camo.githubusercontent.com/abee5ba661f74838ba262821e192d55b928209b9b1f9df4923c6feda984fd524/68747470733a2f2f636f6465636f762e696f2f67682f4a616e69735665707269732f7a706c2d6275696c6465722d7068702f67726170682f62616467652e7376673f746f6b656e3d4e4e4e434b36394f4955)](https://codecov.io/gh/JanisVepris/zpl-builder-php)

zpl-builder-php
===============

[](#zpl-builder-php)

A small PHP 8.3+ library that generates [ZPL II](https://docs.zebra.com/us/en/printers/software/zpl-pg/zpl-ii,-zbi-2,-set-get-do,-mirror,-wml-programming-guide.html) (Zebra Programming Language) label payloads via a fluent builder API. No runtime dependencies beyond PHP itself.

> **Status:** work in progress — the public API is **unstable until 1.0** and minor releases may include breaking changes. See [`CHANGELOG.md`](CHANGELOG.md) for the per-version breakdown.

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

[](#installation)

```
composer require janisvepris/zpl-builder-php
```

Supported PHP versions: **8.3, 8.4, 8.5**.

Quick example
-------------

[](#quick-example)

```
use Janisvepris\ZplBuilder\Enum\Font;
use Janisvepris\ZplBuilder\ZplBuilder;

$zpl = (string) ZplBuilder::start()
    ->labelHome(30, 30)
    ->changeFont(Font::Zero, 40, 20)
    ->fieldOrigin(50, 50)
    ->fieldData('Hello, ZPL!')
    ->fieldOrigin(50, 120)
    ->barcodeDefaults(3, 3.0, 100)
    ->barcodeCode128('ABC123')
    ->printQuantity(1)
    ->end();

// ^XA^LH30,30^CF0,40,20^FO50,50^FDHello, ZPL!^FS^FO50,120^BY3,3.0,100^BCN,100,Y,N,N,N^FDABC123^FS^PQ1^XZ
```

Send the resulting string to a Zebra printer over its preferred transport (raw TCP on port 9100, USB, serial, etc.).

Features
--------

[](#features)

- Fluent builder with one method per ZPL command, named after the command's purpose (`fieldOrigin`, `changeFont`, `barcodeCode128`, …).
- Typed enums for ZPL parameters (`Orientation`, `Justify`, `Code128Mode`, `Font`, `Encoding`, …) instead of bare strings.
- Constructor-time validation on all command value objects — out-of-range numeric inputs throw a typed `RangeException` subclass before the printer ever sees them.
- Auto-escape of `^` and `~` in field data via `^FH` so user content can't accidentally be interpreted as commands.
- Escape hatch: `->raw('…')` for any ZPL fragment the builder doesn't yet model.
- Subclassable — no class is `final`, so downstream consumers can add their own fluent methods or command value objects.

Escape hatch for unsupported commands
-------------------------------------

[](#escape-hatch-for-unsupported-commands)

The library doesn't yet have dedicated methods for every ZPL command. For anything missing, pass a literal fragment through `raw()`:

```
ZplBuilder::start()
    ->raw('^MD15')          // media darkness — no native method yet
    ->raw('^PR4,4,4')       // print rate
    ->end();
```

Reference
---------

[](#reference)

- [Zebra ZPL II Programming Guide](https://www.zebra.com/content/dam/support-dam/en/documentation/unrestricted/guide/software/zpl-zbi2-pg-en.pdf)
- [Online command reference (alphabetical index)](https://docs.zebra.com/us/en/printers/software/zpl-pg/c-zpl-zpl-commands.html)

License
-------

[](#license)

MIT — see [`LICENSE`](LICENSE).

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance99

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

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

Every ~7 days

Total

20

Last Release

3d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5411fe0f3265bae86714324a926cf7c33dee66d761a679dda36a28ea5f5d0dc6?d=identicon)[janisvepris](/maintainers/janisvepris)

---

Top Contributors

[![JanisVepris](https://avatars.githubusercontent.com/u/4033838?v=4)](https://github.com/JanisVepris "JanisVepris (296 commits)")

---

Tags

printerbarcodelabelzebrazpl

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/janisvepris-zpl-builder-php/health.svg)

```
[![Health](https://phpackages.com/badges/janisvepris-zpl-builder-php/health.svg)](https://phpackages.com/packages/janisvepris-zpl-builder-php)
```

###  Alternatives

[mike42/escpos-php

PHP receipt printer library for use with ESC/POS-compatible thermal and impact printers

2.8k2.1M25](/packages/mike42-escpos-php)[ramytalal/label-printer

An implementation of the Brother label printer API.

6543.4k](/packages/ramytalal-label-printer)[php-aidc/label-printer

Easily create and print labels on various label printers

6024.4k](/packages/php-aidc-label-printer)[ayeo/gs1_barcode

Generate GS1-128 standard barcode

52119.6k](/packages/ayeo-gs1-barcode)[bitgrave/barcode-bundle

provide barcode rendering service into your Symfony2 application.

24447.2k1](/packages/bitgrave-barcode-bundle)[z38/metzli

PHP library to generate Aztec barcodes

26330.2k](/packages/z38-metzli)

PHPackages © 2026

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