定制 janisvepris/zpl-builder-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

janisvepris/zpl-builder-php

最新稳定版本:0.60.0

Composer 安装命令:

composer require janisvepris/zpl-builder-php

包简介

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

README 文档

README

GitHub Actions Workflow Status codecov

zpl-builder-php

A small PHP 8.3+ library that generates ZPL II (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 for the per-version breakdown.

Installation

composer require janisvepris/zpl-builder-php

Supported PHP versions: 8.3, 8.4, 8.5.

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

  • 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

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

License

MIT — see LICENSE.

统计信息

  • 总下载量: 2.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固