alves / escpos-php
PHP receipt printer library for use with ESC/POS-compatible thermal and impact printers
Installs: 3
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/alves/escpos-php
Requires
- php: >=7.0.0
- ext-intl: *
- ext-json: *
- ext-zlib: *
- alves/gfx-php: ^1.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.3
Suggests
- ext-gd: Used for image printing if present.
- ext-imagick: Will be used for image printing if present. Required for PDF printing or use of custom fonts.
README
A PHP library implementing a subset of Epson’s ESC/POS protocol for thermal receipt printers.
It allows PHP applications to generate and print receipts with text formatting, images, barcodes, QR codes, paper cutting and cash drawer control, without relying on vendor-specific SDKs.
This library is suitable for web-based POS systems, desktop services and server-side printing workflows.
✨ Features
- ESC/POS command abstraction for PHP
- Multiple connection types (USB, serial, network, CUPS, SMB, LPT)
- Text formatting, alignment and styles
- Image printing (with optional GD / Imagick acceleration)
- Barcode, QR Code and PDF417 support
- Cash drawer control
- Capability profiles for different printer models
🖨️ Compatibility
Interfaces & Operating Systems
This driver is known to work with the following OS / interface combinations:
| Interface | Linux | macOS | Windows |
|---|---|---|---|
| Ethernet | Yes | Yes | Yes |
| USB | Yes | Not tested | Yes |
| USB-Serial | Yes | Yes | Yes |
| Serial | Yes | Yes | Yes |
| Parallel | Yes | Not tested | Yes |
| SMB Shared | Yes | No | Yes |
| CUPS Hosted | Yes | Yes | No |
See the example/interface/ directory for working examples.
Supported Printers
Many ESC/POS-compatible printers are known to work with this library, including models from:
- Epson
- Bematech
- Elgin
- Bixolon
- Star
- Daruma
- Rongta
- Xprinter
- Zjiang
(and many others — see full list above)
If your printer works and is not listed, please open an issue so it can be added.
🚀 Installation
Requirements
- PHP 7.3 or newer
jsonextensionintlextensionzlibextension
Optional (recommended for better image performance):
gdimagick
Composer
composer require alves/escpos-php
Basic Usage
<?php require __DIR__ . '/vendor/autoload.php'; use Alves\Escpos\PrintConnectors\FilePrintConnector; use Alves\Escpos\Printer; $connector = new FilePrintConnector("php://stdout"); $printer = new Printer($connector); $printer->text("Hello World!\n"); $printer->cut(); $printer->close();