dashed/receiptprinter
Composer 安装命令:
composer require dashed/receiptprinter
包简介
:description
关键字:
README 文档
README
Simple Laravel package to integrate ESC/POS Print Driver for PHP.
Installation
Via Composer
$ composer require Dashed/receiptprinter
Sample App
I have set up a simple app based on Laravel 7 to serve as a demo.
Usage
Execute the following command to publish the config used by this package:
$ php artisan vendor:publish --tag=receiptprinter.config
Edit the config file located at config/receiptprinter.php as follows:
- Set
connector_typeto:windowsif you are using Windows as your web server.cupsif you are using Linux or Mac as your web server.networkif you are using a network printer.
- Set
connector_descriptorto:- the printer name if your
connector_typeis eitherwindowsorcups - the IP address or Samba URI, e.g:
smb://192.168.0.5/PrinterNameif yourconnector_typeisnetwork
- the printer name if your
- Set
connector_portto the open port for the printer, only if yourconnector_typeisnetwork
Include the library:
use Dashed\ReceiptPrinter\ReceiptPrinter as ReceiptPrinter;
Then use any one of these two functions to send "print" command to the printer.
printReceipt()
printRequest()
Example (Print Receipt)
use Dashed\ReceiptPrinter\ReceiptPrinter as ReceiptPrinter;
...
// Set params
$mid = '123123456';
$store_name = 'YOURMART';
$store_address = 'Mart Address';
$store_phone = '1234567890';
$store_email = 'yourmart@email.com';
$store_website = 'yourmart.com';
$tax_percentage = 10;
$transaction_id = 'TX123ABC456';
$currency = 'Rp';
$image_path = 'logo.png';
// Set items
$items = [
[
'name' => 'French Fries (tera)',
'qty' => 2,
'price' => 65000,
],
[
'name' => 'Roasted Milk Tea (large)',
'qty' => 1,
'price' => 24000,
],
[
'name' => 'Honey Lime (large)',
'qty' => 3,
'price' => 10000,
],
[
'name' => 'Jasmine Tea (grande)',
'qty' => 3,
'price' => 8000,
],
];
// Init printer
$printer = new ReceiptPrinter;
$printer->init(
config('receiptprinter.connector_type'),
config('receiptprinter.connector_descriptor')
);
// Set store info
$printer->setStore($mid, $store_name, $store_address, $store_phone, $store_email, $store_website);
// Set currency
$printer->setCurrency($currency);
// Add items
foreach ($items as $item) {
$printer->addItem(
$item['name'],
$item['qty'],
$item['price']
);
}
// Set tax
$printer->setTax($tax_percentage);
// Calculate total
$printer->calculateSubTotal();
$printer->calculateGrandTotal();
// Set transaction ID
$printer->setTransactionID($transaction_id);
// Set logo
// Uncomment the line below if $image_path is defined
//$printer->setLogo($image_path);
// Set QR code
$printer->setQRcode([
'tid' => $transaction_id,
]);
// Print receipt
$printer->printReceipt();
Example (Print Request)
use Dashed\ReceiptPrinter\ReceiptPrinter as ReceiptPrinter;
...
// Set params
$mid = '123123456';
$store_name = 'YOURMART';
$store_address = 'Mart Address';
$store_phone = '1234567890';
$store_email = 'yourmart@email.com';
$store_website = 'yourmart.com';
$tax_percentage = 10;
$transaction_id = 'TX123ABC456';
$currency = 'Rp';
$image_path = 'logo.png';
// Init printer
$printer = new ReceiptPrinter;
$printer->init(
config('receiptprinter.connector_type'),
config('receiptprinter.connector_descriptor')
);
// Set store info
$printer->setStore($mid, $store_name, $store_address, $store_phone, $store_email, $store_website);
// Set currency
$printer->setCurrency($currency);
// Set request amount
$printer->setRequestAmount($request_amount);
// Set transaction ID
$printer->setTransactionID($transaction_id);
// Set logo
// Uncomment the line below if $image_path is defined
//$printer->setLogo($image_path);
// Set QR code
$printer->setQRcode([
'tid' => $transaction_id,
'amount' => $request_amount,
]);
// Print payment request
$printer->printRequest();
Changelog
Please see the changelog for more information on what has changed recently.
Contributing
Please see contributing.md for details and a todolist.
Problems
If you discover any issues, please post the details on the issue tracker.
Credits
- Mike42 for the awesome PHP ESC/POS Print Driver library
License
MIT. Please see the license file for more information.
dashed/receiptprinter 适用场景与选型建议
dashed/receiptprinter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 252 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 09 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「ReceiptPrinter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dashed/receiptprinter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dashed/receiptprinter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dashed/receiptprinter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
:description
:description
Alfabank REST API integration
:description
Laravel package for Accurate Online API integration.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 252
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-25