janisvepris/zpl-builder-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

janisvepris/zpl-builder-php

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.

janisvepris/zpl-builder-php 适用场景与选型建议

janisvepris/zpl-builder-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.46k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 02 月 09 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「barcode」 「label」 「printer」 「zebra」 「zpl」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 janisvepris/zpl-builder-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 janisvepris/zpl-builder-php 我们能提供哪些服务?
定制开发 / 二次开发

基于 janisvepris/zpl-builder-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

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