Download the PHP package beziworld/laravel-label-printing without Composer
On this page you can find all versions of the php package beziworld/laravel-label-printing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download beziworld/laravel-label-printing
More information about beziworld/laravel-label-printing
Files in beziworld/laravel-label-printing
Package laravel-label-printing
Short Description Label and receipt printing for Laravel: named printers over TCP 9100, CUPS and Windows shares, a ZPL builder, ESC/POS receipts with Polish code pages, courier label passthrough and queued print jobs.
License MIT
Homepage https://github.com/beziworld/laravel-label-printing
Informations about the package laravel-label-printing
Laravel Label Printing
Server side printing of shipping labels and non-fiscal receipts from Laravel:
- named printers in config: raw TCP (port 9100), CUPS (
lp -o raw), Windows shares (\\HOST\Printer), files or device nodes, and a null driver - raw passthrough of ZPL and EPL labels returned by courier APIs (InPost, DPD, DHL, GLS, UPS ...), plain or base64
- a typed ZPL II builder: text, text blocks, Code 128, EAN-13, EAN-8, Code 39, QR, boxes, lines and PNG graphics
- an ESC/POS receipt builder on top of mike42/escpos-php: styles, alignment, columns, barcodes, QR, logo, cut, cash drawer, and Polish characters through an explicit code page (PC852 by default)
- queued
PrintJobthat retries connection failures only,PrintSucceeded/PrintFailedevents LabelPrinter::fake()capturing the exact bytes, and an artisan test page command
Polska wersja dokumentacji
Why this package
Packagist (November 2026) has mike42/escpos-php (2.6M downloads) and robgridley/zebra (2.2M) as framework agnostic libraries, but the Laravel side is thin: charlieuki/receiptprinter wraps escpos-php 2.x and is no longer maintained, abdullah-life/laravel-zebra-image-printer only converts PNG to ZPL, and the QZ Tray / Web Serial packages print from the browser, not from the server. None of them gives you named printers, courier ZPL passthrough, queued jobs with safe retries and test fakes in one place.
This package depends on mike42/escpos-php ^5.0 (MIT, maintained, PHP 8.2+) for ESC/POS command rendering. The ZPL builder is written here, because robgridley/zebra has not been released since 2022 and calls imagedestroy(), which is deprecated in PHP 8.5.
Installation
Requires PHP 8.3+, Laravel 12 or 13, ext-intl (required by escpos-php) and ext-gd for images.
Configuration
| Driver | How bytes are delivered |
|---|---|
network |
TCP socket to host:port (JetDirect / AppSocket, usually 9100) |
cups |
lp [-h host] -d destination -o raw [-o ...] - with the job on standard input |
windows |
On Windows: written to the UNC path. Elsewhere: smbclient //HOST/Printer -c 'print -', password in the PASSWD environment variable. method forces copy or smbclient |
file |
file_put_contents() to a file or a device such as /dev/usb/lp0; append keeps a capture log |
null |
Discards the job |
language (zpl, epl, escpos, raw) protects you from sending a receipt to a label printer or the other way round; raw printers accept anything. Printers are validated when first used, so one incomplete definition does not break the others.
Print courier labels (ZPL / EPL passthrough)
zpl() checks that the data contains ^XA, epl() that it contains a P print command. Ask the courier API for ZPL or EPL: thermal printers in these modes cannot print PDF labels.
Build a ZPL label
Text is sent as UTF-8 under ^CI28; ^, ~, _ and \ are escaped with ^FH. Whether Polish letters print depends on the font in the printer (font 0 on current Zebra firmware is the usual choice). Images are thresholded to black and white and sent as an uncompressed ^GFA graphic; transparent pixels are white.
Print an ESC/POS receipt
The receipt starts with ESC @ and ESC t n and all text is encoded into that one code page:
code_page |
Default ESC t |
Polish |
|---|---|---|
cp852 (default) |
18 | yes |
cp1250 |
45 | yes |
iso8859-2 |
39 | yes |
cp858 |
19 | no (Western European, euro sign) |
cp437 |
0 | no |
Table numbers follow the Epson numbering. Many clones use different numbers: print the test page and set code_page_table if the letters come out wrong. Characters missing from the code page are transliterated (€ becomes EUR in PC852) or replaced with ?. profile is an escpos-php capability profile (default, TM-T88V, simple, ...); features the profile lacks (for example QR on simple) raise InvalidPayload.
These are non-fiscal printouts: fiscal printers and cash register protocols are out of scope.
Queue print jobs
Payloads are rendered before dispatch and stored base64 encoded, so the worker prints exactly the bytes you built. PrintJob retries only ConnectionFailed (the printer could not be reached, nothing was sent), with the configured tries and backoff. Any other error, including a connection that dropped in the middle of a job, fails the job immediately, because a retry could print the label twice. Runtime printers created with using() travel inside the job payload, including their credentials.
Runtime printers and events
| Event | Payload |
|---|---|
PrintSucceeded |
$result (PrintResult: printer, endpoint, language, bytes, copies, durationMs, reference) |
PrintFailed |
printer, language, bytes, exception, retryable, reference |
Raw printer protocols have no acknowledgement: success means the transport accepted every byte, not that the label left the printer.
Test page
Testing your code
Errors
All exceptions extend Beziworld\LabelPrinting\Exceptions\LabelPrintingException; isRetryable() tells whether a retry is safe.
| Exception | When | Retried by PrintJob |
|---|---|---|
InvalidConfiguration |
missing or invalid printer settings, unknown printer, unknown profile | no |
InvalidPayload |
malformed ZPL / EPL / base64, invalid barcode data, wrong language for the printer | no |
ConnectionFailed |
socket connect failed, CUPS scheduler or SMB host unreachable | yes |
TransportFailed |
write broke off, lp / smbclient rejected the job, file not writable |
no |
Development
Tests never touch real printers: transports are faked, lp and smbclient run through Process::fake(), and the TCP transport is exercised against a local listener on 127.0.0.1. Builder tests assert exact bytes.
Author
Created and maintained by Kamil Ćwiertnia, beziworld.eu.
- E-mail: [email protected]
- Issues: GitHub issues
Need an integration? Get in touch through beziworld.eu.
Other packages by the author
laravel-inpost · laravel-dpd · laravel-dhl-parcel · laravel-gls · laravel-ups
License
MIT. See LICENSE.md. This package is not affiliated with Zebra Technologies, Seiko Epson, the CUPS or Samba projects, or any courier.
All versions of laravel-label-printing with dependencies
ext-intl Version *
ext-json Version *
illuminate/bus Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/events Version ^12.0|^13.0
illuminate/process Version ^12.0|^13.0
illuminate/queue Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
mike42/escpos-php Version ^5.0