whereof/cloud-print
Composer 安装命令:
composer require whereof/cloud-print
包简介
非官方云小票机SDK,支持飞鹅云,芯烨云,易联云,快递100,映美云,中午云,佳博云,优声云,365智能云打印等
README 文档
README
云小票机SDK-cloud-print
非官方云小票机SDK,支持飞鹅云,芯烨云,易联云,快递100,映美云,中午云,佳博云,优声云,365智能云打印等
安装
composer require pkg6/cloud-print
自定义缓存
基于https://packagist.org/packages/psr/simple-cache#1.0
public function setCache(CacheInterface $cache);
自定义日志
基于 https://packagist.org/packages/psr/log
public function setRequestLogger(LoggerInterface $logger) //自定义日志格式(借助guzzlehttp/guzzle中的handler)进行实现 public function setMessageFormatter(MessageFormatter $messageFormatter)
适配模式
需要定义的服务商实现客户端
https://github.com/pkg6/cloud-print/blob/main/src/Contracts/ClientInterface.php
配置
https://github.com/pkg6/cloud-print/blob/main/config/config.php
实例化
$cloudPrint = new CloudPrint($config)
//自定义驱动
$cloudPrint->client("zhongwuyun")->request($method, $action, $privateParams)
//默认驱动
$cloudPrint->request($method, $action, $privateParams)
统一打印协议
所有厂商客户端实现统一的
print(PrintRequest $request)方法,通过PrintRequest参数类传递打印参数。
PrintRequest 参数
| 参数 | 类型 | 说明 |
|---|---|---|
sn |
string |
打印机编号 |
content |
string |
打印内容 |
copies |
int |
打印份数,默认 1 |
orderId |
string |
订单号 |
type |
string |
打印类型(厂商差异) |
templateId |
string |
模板ID |
imageUrl |
string |
图片地址 |
htmlUrl |
string |
HTML地址 |
extra |
array |
各厂商私有扩展字段 |
基本用法
use Pkg6\CloudPrint\Requests\PrintRequest;
$request = PrintRequest::create()
->sn('99999999')
->content('订单内容')
->copies(1)
->orderId('12345');
$client->print($request);
使用 type 参数
// 飞鹅云 - 标签打印
$request = PrintRequest::create()
->sn('99999999')
->content('标签内容')
->type('label');
// 映美云 - 多种打印模式
$request = PrintRequest::create()
->sn('99999999')
->htmlUrl('https://example.com/order.html')
->type('html_url'); // html_code / html_to_pic / template / express / esc 等
// 易联云 - 图片打印
$request = PrintRequest::create()
->sn('99999999')
->imageUrl('https://example.com/image.png')
->type('picture');
厂商 type 映射表
| 厂商 | type 值 | 说明 |
|---|---|---|
| 飞鹅云 | label |
标签打印 |
| 芯烨云 | label |
标签打印 |
| 易联云 | picture / express |
图片打印 / 面单打印 |
| 映美云 | html_url / html_code / html_to_pic / html_to_gray_pic / template / point_text / express / rich_html_code / esc / file / file_by_url / label / invoice |
13种打印模式 |
| 其余厂商 | 默认 | 文本打印 |
门脸模式
可以直接到实现请求的客户端,内置很多方法可以供使用
基于中午云的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Zhongwuyun([
'appid' => '******',
'appsecret' => '******',
]);
基于 优声云 的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Ushengyun([
'appId' => '10001',
'appSecret' => '**********',
]);
基于佳博云的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Poscom([
'memberCode' => '',
'apiKey' => '',
]);
基于快递100的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Kuaidi100([
'key' => '',
'secret' => '',
]);
基于易联云的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Yilianyun([
'client_id' => '',
'client_secret' => '',
]);
基于映美云的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Jolimark([
'app_id' => '',
'app_key' => '',
]);
基于 芯烨云 的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Xpyun([
'user' => '',
'userKey' => '',
]);
基于 飞鹅云 的 PHP 接口组件
$printer = \Pkg6\CloudPrint\Factory::Feieyun([
'user' => '',
'ukey' => '',
]);
支持厂商
加入我们
如果你认可我们的开源项目,有兴趣为 cloud-print 的发展做贡献,竭诚欢迎加入我们一起开发完善。无论是 报告错误issues 或是 Pull Request 开发,那怕是修改一个错别字也是对我们莫大的帮助。
许可协议
whereof/cloud-print 适用场景与选型建议
whereof/cloud-print 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.96k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2021 年 09 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「快递100」 「云打印机」 「云小票机」 「芯烨云」 「Cloud Print」 「飞鹅云」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 whereof/cloud-print 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 whereof/cloud-print 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 whereof/cloud-print 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
高扩展性云小票打印SDK,支持飞鹅云、芯烨云、易联云、快递100、映美云、佳博云、中午云、优声云等主流云打印服务,兼容 Laravel、ThinkPHP 等主流框架,统一API,易集成,易扩展。
非官方云小票机SDK,支持飞鹅云,芯烨云,易联云,快递100,映美云,中午云,佳博云,优声云,365智能云打印等
A flexible and awesome shipment tracking library for several carriers like DHL eCommerce, USPS, YanWen Express, Epacket, E包裹, E特快, 国际EMS, 快递100
A flexible and shipment tracking library for Kuaidi100.
PHP Wrapper for KuaiDi100
云打印机
统计信息
- 总下载量: 4.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-18