定制 survos/zebra-bundle 二次开发

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

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

survos/zebra-bundle

Composer 安装命令:

composer require survos/zebra-bundle

包简介

Symfony bundle for Zebra ZPL preview and printing workflows

README 文档

README

Symfony bundle for Zebra ZPL preview and printing workflows.

Status

This bundle is small and focused: it previews Zebra ZPL through Labelary and sends print jobs through common server-side transports.

Current features:

  • SurvosZebraBundle using AbstractBundle
  • In-bundle service registration without services.php
  • Labelary-backed preview client and cache wrapper
  • Twig extension with zpl_preview() support
  • Optional Twig component for label preview
  • TCP, CUPS, file, USB, and null print transports

BrowserPrint/client-side USB support is intentionally not part of the current server-side bundle surface.

Configuration

survos_zebra:
  labelary:
    endpoint: 'https://api.labelary.com/v1'
    api_key: null
    timeout: 10
  cache:
    enabled: true
    pool: cache.app
    ttl: 86400
  defaults:
    label_size: gk420d_2_25x1_25
    dpmm: 8
    width_inches: 4.0
    height_inches: 2.0
    format: png
  label_sizes:
    gk420d_2_25x1_25:
      width_inches: 2.25
      height_inches: 1.25
      dpmm: 8
      description: 'Zebra GK420d 2.25 x 1.25 inch label'
  printers:
    zebra:
      type: cups
      queue: zebra
      dpi: 203
      label_width_in: 2.25
      label_height_in: 1.25
    spool:
      type: file
      path: '%kernel.project_dir%/var/zpl'
      dpi: 203
      label_width_in: 2.25
      label_height_in: 1.25
  default_printer: zebra

For USB-attached GK420d printers on Linux, prefer a CUPS queue that uses the CUPS USB backend, for example usb://Zebra/..., then print with type: cups. Avoid writing directly to /dev/usb/lp*; that path depends on usblp and can leave transport and interpreter failures hard to distinguish. See docs/gk420d-reliable-printing.md.

The print service automatically prepends the ZPL interpreter guard:

^XA^SZ2^XZ

It also wraps each label with the configured media dimensions:

^XA
^PW457
^LL254
...label body...
^XZ

Do not rely on printer-stored defaults for print width or label length. A GK420d defaults to a 4 inch print width, so narrower stock can produce blank or partial labels when content lands outside the physical media. Configure each printer profile with dpi, label_width_in, and label_height_in; the bundle converts inches to dots with:

dots = inches * dpi

Common 203 dpi sizes:

Label size ^PW ^LL
2.25 x 1.25 in 457 254
2.25 x 1 in 457 203
4 x 6 in 812 1218
4 x 2 in 812 406
3 x 1 in 609 203

PrinterServiceInterface::testLabel() prints a small known-good label using the configured dimensions. calibrate() sends ^XA^JC^XZ for new media. saveSettings() persists ^PW and ^LL with ^JUS, but should be treated as an advanced single-printer setup command; normal jobs remain explicit per print.

Twig Usage

<img src="{{ zpl_preview(zpl) }}" alt="Label preview">

Named label sizes are also supported:

<img src="{{ zpl_preview(zpl, 'gk420d_2_25x1_25') }}" alt="GK420d label preview">

If symfony/ux-twig-component is installed, the bundle also registers:

<twig:Zebra:Preview :zpl="zpl" />

You can override the configured default size per component render:

<twig:Zebra:Preview :zpl="zpl" labelSize="gk420d_2_25x1_25" />

Verification

This repository includes a dependency-light smoke test for the bundle primitives:

php smoke-test.php
composer validate --strict

survos/zebra-bundle 适用场景与选型建议

survos/zebra-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 88 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 survos/zebra-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-24