Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Escpos Php Laravel Package

mike42/escpos-php

A PHP driver implementing the ESC/POS protocol for thermal receipt printers. Generate and print receipts with formatting, cutting and barcodes over Ethernet, USB, serial, parallel or SMB, making it easy to add receipt printing to POS apps.

View on GitHub
Deep Wiki
Context7

mike42/escpos-php is a PHP driver that implements a subset of Epson's ESC/POS protocol for thermal receipt printers. It lets PHP applications—especially web-based point-of-sale (POS) systems—generate and print receipts with formatting, cutting, and barcodes on compatible hardware.

The library supports multiple connection methods across Linux, Mac, and Windows, including Ethernet, USB, serial, parallel, and SMB shared printers.

Features:

  • Text formatting: bold, underline, alignment, and font sizing
  • Barcode and QR code generation
  • Receipt cutting and cash drawer control
  • Image printing support
  • Works with USB, network, serial, and SMB interfaces
Frequently asked questions about Escpos Php
What is mike42/escpos-php and can I use it in a Laravel application?
mike42/escpos-php is a framework-agnostic PHP library that generates ESC/POS byte streams for thermal and impact receipt printers, covering formatting, barcodes, and paper cuts. It has no framework coupling and no global state, so a single service provider that binds a Printer wrapper around a PrintConnector is essentially the entire integration. Most teams hide it behind their own domain interface such as a ReceiptPrinterContract so call sites never touch the driver directly.
How do I install mike42/escpos-php with Composer in Laravel?
Run composer require mike42/escpos-php, which works out of the box on PHP 7.3 and above. The library requires the json, intl, and zlib extensions, and imagick or gd is strongly recommended for image handling. In Laravel, construct the connector and Printer inside a service provider and resolve them from the container rather than instantiating printers inline.
Which PHP and Laravel versions does mike42/escpos-php support?
The package requires PHP 7.3 or later, which covers Laravel 8 through Laravel 11. It is not a Laravel package, so there is no Laravel-specific version matrix, but PHP 8.x compatibility and upstream release cadence should be confirmed against your target framework version. Watch for the intl extension, which is frequently missing from slim production images and is non-negotiable for code-page conversion.
How do I print to a network thermal printer on port 9100 from Laravel?
Use NetworkPrintConnector with the printer's IP address and port 9100 for raw TCP, then pass it to a Printer instance alongside the matching CapabilityProfile. The PHP process must have network egress to the printer, so in practice the printer has to sit on the same L2/L3 segment as the app. For a hosted application this usually means a store-local print agent or bridge service rather than direct printing from the cloud.
Can a cloud-hosted Laravel app print directly to a USB or serial receipt printer?
No. The USB, parallel, and /dev/* connectors require the printer to be physically attached to the machine running PHP, so they are unusable inside a container or a cloud VM. Hosted POS setups typically run a small store-local print agent that reaches printers on the LAN while the central Laravel app dispatches jobs to it. WindowsPrintConnector and CupsPrintConnector also depend on an OS print queue on the same host.
Why are accented characters, currency symbols, or cut commands printing incorrectly?
ESC/POS is a family of vendor dialects rather than a single specification, so garbled currency symbols, broken accented characters, and ignored cut commands are the expected failure class. Select the correct CapabilityProfile for the printer model and fall back to the simple profile when a specific unit misbehaves. The intl extension matters here because it drives code-page conversion.
Is mike42/escpos-php still maintained and what is its license?
The project is effectively a single-maintainer library, so treat bus factor as a real risk and plan a vendor-patch or fork policy if upstream cadence stalls. GitHub's licensee reports NOASSERTION for the LICENSE file even though the README advertises MIT, so a legal review of the actual license file is a gating step. Verify too that release tags are genuinely tested rather than metadata artifacts.
How do I test receipt printing in Laravel without a physical printer?
Use FilePrintConnector with php://memory or a temp file to capture the generated byte stream and assert on it, which removes hardware from your test suite. Build a small printer lab with two or three real units from your fleet for final validation of formatting, barcodes, and cuts. Mock your own ReceiptPrinterContract in feature tests and reserve byte-stream assertions for driver-level tests.
How do I print logos, images, and barcodes with mike42/escpos-php?
Graphics, barcodes, and paper cuts are all part of the supported ESC/POS subset exposed by the Printer API. Install imagick or gd to avoid slow PHP-side image rasterization when printing logos. Barcode support varies by printer model, so test the specific symbologies you need on real hardware and confirm them against your CapabilityProfile.
What are the alternatives to mike42/escpos-php and how do I swap it out later?
Because the library is dependency-light and framework-agnostic, the cleanest approach is to wrap it behind your own interface, such as ReceiptPrinterContract, so an alternative driver can be dropped in without touching call sites. Alternatives range from vendor SDKs to cloud print services, most of which bring heavier dependencies or per-print costs. Decide early whether duplicate receipts are acceptable or whether you need idempotency, since this library provides no job state, retries, or delivery acknowledgements.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle