# ESC/POS Print Driver for PHP
[](https://travis-ci.org/mike42/escpos-php) [](https://packagist.org/packages/mike42/escpos-php)
[](https://packagist.org/packages/mike42/escpos-php)
[](https://packagist.org/packages/mike42/escpos-php)
[](https://coveralls.io/github/mike42/escpos-php?branch=development)
This project implements a subset of Epson's ESC/POS protocol for thermal receipt printers. It allows you to generate and print receipts with basic formatting, cutting, and barcodes on a compatible printer.
The library was developed to add drop-in support for receipt printing to any PHP app, including web-based point-of-sale (POS) applications.
## Compatibility
### Interfaces and operating systems
This driver is known to work with the following OS/interface combinations:
<table>
<tr>
<th> </th>
<th>Linux</th>
<th>Mac</th>
<th>Windows</th>
</tr>
<tr>
<th>Ethernet</th>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</a></td>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</a></td>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/ethernet.php">Yes</a></td>
</tr>
<tr>
<th>USB</th>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/linux-usb.php">Yes</a></td>
<td>Not tested</td>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-usb.php">Yes</a></td>
</tr>
<tr>
<th>USB-serial</th>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<th>Serial</th>
<td>Yes</td>
<td>Yes</td>
<td>Yes</td>
</tr>
<tr>
<th>Parallel</th>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/windows-lpt.php">Yes</a></td>
<td>Not tested</td>
<td>Yes</td>
</tr>
<tr>
<th>SMB shared</th>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">Yes</a></td>
<td>No</td>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/smb.php">Yes</a></td>
</tr>
<tr>
<th>CUPS hosted</th>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/cups.php">Yes</a></td>
<td><a href="https://github.com/mike42/escpos-php/tree/master/example/interface/cups.php">Yes</a></td>
<td>No</td>
</tr>
</table>
### Printers
Many thermal receipt printers support ESC/POS to some degree. This driver has been known to work with:
- 3nStar RPT-008
- Approx APPPOS80AM
- AURES ODP-333
- AURES ODP-500
- Bematech-4200-TH
- Bematech LR2000E
- Birch PRP-085III
- Bixolon SRP-350III
- Bixolon SRP-350Plus
- Black Copper BC-85AC
- CHD TH-305N
- Citizen CBM1000-II
- Citizen CT-S310II
- Dapper-Geyi Q583P
- Daruma DR800
- DR-MP200 (manufacturer unknown)
- EPOS TEP 220M
- Elgin i9
- Epson EU-T332C
- Epson FX-890 (requires `feedForm()` to release paper).
- Epson TM-T20
- Epson TM-T20II
- Epson TM-T70
- Epson TM-T70II
- Epson TM-T81
- Epson TM-T82II
- Epson TM-T88II
- Epson TM-T88III
- Epson TM-T88IV
- Epson TM-T88V
- Epson TM-U220
- Epson TM-U295 (requires `release()` to release slip).
- Epson TM-U590 and TM-U590P
- Equal (EQ-IT-001) POS-58
- Everycom EC-58
- Excelvan HOP-E200
- Excelvan HOP-E58
- Excelvan HOP-E801
- Gainscha GP-2120TF
- Gainscha GP-5890x (Also marketed as EC Line 5890x)
- Gainscha GP-U80300I (Also marketed as gprinter GP-U80300I)
- gprinter GP-U80160I
- HOIN HOP-H58
- Ithaca iTherm 28
- Hasar HTP 250
- Metapace T-1
- Metapace T-25
- Nexa PX700
- Nyear NP100
- OKI RT322
- OKI 80 Plus III
- Orient BTP-R580
- P-822D
- P85A-401 (make unknown)
- Partner Tech RP320
- POSLIGNE ODP200H-III-G
- QPOS Q58M
- Rongta RP326US
- Rongta RP58-U
- Rongta RP80USE
- SAM4S GIANT-100DB
- Senor TP-100
- Sewoo SLK-TS400
- SEYPOS PRP-96
- SEYPOS PRP-300 (Also marketed as TYSSO PRP-300)
- SNBC BTP-R880NPIII
- Solux SX-TP-88300
- Sicar POS-80
- Silicon SP-201 / RP80USE
- SPRT SP-POS88V
- Star BSC10
- Star TSP100 ECO
- Star TSP100III FuturePRNT
- Star TSP-650
- Star TUP-592
- TVS RP45 Shoppe
- Venus V248T
- Xeumior SM-8330
- Xprinter F-900
- Xprinter XP-365B
- Xprinter XP-58 Series
- Xprinter XP-80C
- Xprinter XP-90
- XPrinter XP-Q20011
- Xprinter XP-Q800
- Zjiang NT-58H
- Zjiang ZJ-5870
- Zjiang ZJ-5890 (Also sold as POS-5890 by many vendors; ZJ-5890K, ZJ-5890T also work).
- Zjiang ZJ-8220 (Also marketed as Excelvan ZJ-8220)
- Zjiang ZJ-8250
If you use any other printer with this code, please [let us know](https://github.com/mike42/escpos-php/issues/new) so that it can be added to the list.
## Basic usage
### Include the library
#### Composer
This library is designed for use with the `composer` PHP dependency manager. Simply add the `mike42/escpos-php` package to get started:
```bash
composer require mike42/escpos-php
```
If you haven't used `composer` before, you can read about it at [getcomposer.org](https://getcomposer.org/).
#### Requirements
This project has few hard dependencies:
- PHP 7.0 or newer.
- `json` extension, used to load bundled printer definitions (see [documentation](https://www.php.net/manual/en/book.json.php))
- `intl` extension, used for character encoding (see [documentation](https://www.php.net/manual/en/book.intl.php))
- `zlib` extension, used for de-compressing bundled resources (see [documentation](https://www.php.net/manual/en/book.zlib.php)).
It is also suggested that you install either `imagick` or `gd`, as these can be used to speed up image processing.
A number of optional extensions can be added to enable more specific features. These
are described in the "suggest" section of [composer.json](https://github.com/mike42/escpos-php/tree/master/composer.json).
### The 'Hello World' receipt
To make use of this driver, your server (where PHP is installed) must be able to communicate with your printer. Start by generating a simple receipt and sending it to your printer using the command-line.
```php
<?php
/* Call this file 'hello-world.php' */
require __DIR__ . '/vendor/autoload.php';
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
$connector = new FilePrintConnector("php://stdout");
$printer = new Printer($connector);
$printer -> text("Hello World!\n");
$printer -> cut();
$printer -> close();
```
Some examples are below for common interfaces.
Communicate with a printer with an Ethernet interface using `netcat`:
```bash
php hello-world.php | nc 10.x.x.x. 9100
```
A USB local printer connected with `usblp` on Linux has a device file (Includes USB-parallel interfaces):
```bash
php hello-world.php > /dev/usb/lp0
```
A computer installed into the local `cups` server is accessed through `lp` or `lpr`:
```bash
php hello-world.php > foo.txt
lpr -o raw -H localhost -P printer foo.txt
```
A local or networked printer on a Windows computer is mapped in to a file, and generally requires you to share the printer first:
```
php hello-world.php > foo.txt
net use LPT1 \\server\printer
copy foo.txt LPT1
del foo.txt
```
If you have troubles at this point, then you should consult your OS and printer system documentation to try to find a working print command.
### Using a PrintConnector
To print receipts from PHP, use the most applicable [PrintConnector](https://github.com/mike42/escpos-php/tree/master/src/Mike42/Escpos/PrintConnectors) for your setup. The connector simply provides the plumbing to get data to the printer.
For example, a `NetworkPrintConnector` accepts an IP address and port:
```php
use Mike42\Escpos\PrintConnectors\NetworkPrintConnector;
use Mike42\Escpos\Printer;
$connector = new NetworkPrintConnector("10.x.x.x", 9100);
$printer = new Printer($connector);
try {
// ... Print stu
没有合适的资源?快使用搜索试试~ 我知道了~
escpos-php:PHP库,用于打印到与ESCPOS兼容的热敏打印机

共142个文件
php:83个
bin:12个
png:10个

需积分: 49 646 浏览量
2021-02-03
00:11:46
上传
评论 1
收藏 684KB ZIP 举报
温馨提示
适用于PHP的ESC / POS打印驱动程序 该项目为热敏票据打印机实现了Epson ESC / POS协议的子集。 它使您可以在兼容的打印机上生成和打印带有基本格式,剪切和条形码的收据。 开发该库是为了向任何PHP应用程序(包括基于Web的销售点(POS)应用程序)添加对收据打印的直接支持。 兼容性 接口和操作系统 已知此驱动程序可用于以下OS /接口组合: Linux 苹果 视窗 乙太网路 USB 未测试 USB串行 是 是 是 序列号 是 是 是 平行 未测试 是 SMB分享了 没有 托管CUPS 没有 印表机 许多热敏票据打印机在某种程度上都支持ESC / POS。 已知该驱动程序可用于: 3nStar RPT-008 约APPPOS80AM AURES ODP-333 AURES ODP-500 Bematech-4200-TH Bematech LR2000E 桦木PRP-085III Bixolon SRP-350III Bixolon SRP-350Plus 黑铜BC-85AC 冠泰TH-305N 公民CBM1000-II 公民CT-S
资源详情
资源评论
资源推荐
收起资源包目录





































































































共 142 条
- 1
- 2



















dongyuwu
- 粉丝: 28
- 资源: 4564
上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制

评论0