PHPackages                             leapfu/cloud-printer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. leapfu/cloud-printer

ActiveLibrary[API Development](/categories/api)

leapfu/cloud-printer
====================

高扩展性云小票打印SDK，支持飞鹅云、芯烨云、易联云、快递100、映美云、佳博云、中午云、优声云等主流云打印服务，兼容 Laravel、ThinkPHP 等主流框架，统一API，易集成，易扩展。

1.0.0(1y ago)125.5k↑55.7%4MITPHPPHP &gt;=8.0

Since Jun 28Pushed 1y agoCompare

[ Source](https://github.com/leapfu/cloud-printer)[ Packagist](https://packagist.org/packages/leapfu/cloud-printer)[ Docs](https://github.com/leapfu/cloud-printer)[ RSS](/packages/leapfu-cloud-printer/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

Cloud Printer
=============

[](#cloud-printer)

**Cloud Printer** 是一款高扩展性、易集成的 PHP 云小票打印 SDK，统一封装了飞鹅云、芯烨云、易联云、快递 100、映美云、佳博云、中午云、优声云等主流云打印服务，支持多驱动切换、主流框架集成、灵活配置和完善的异常处理。

---

主要特性
----

[](#主要特性)

- 🚀 统一 API，屏蔽各家云打印厂商差异
- 🖨️ 支持多种主流云打印机
- 🧩 驱动可扩展，支持自定义云打印服务
- 📝 内置日志、缓存，支持自定义实现
- ⚡ 完善的异常处理体系
- 🛠️ 兼容 Laravel、ThinkPHP 等主流框架
- 📦 Composer 一键安装

---

快速上手
----

[](#快速上手)

### 1. 安装依赖

[](#1-安装依赖)

```
composer require leapfu/cloud-printer
```

### 2. 初始化 SDK

[](#2-初始化-sdk)

```
use Leapfu\CloudPrinter\CloudPrinter;

$config = [
    // 默认打印机类型
    'default'    => 'feie',
    // 缓存配置
    'cache_path' => __DIR__ . '/../cache',
    // 日志目录
    'log_path'   => __DIR__ . '/../logs',
    // HTTP客户端配置
    'http'       => [
        'timeout'         => 30,      // 请求超时时间(秒)
        'connect_timeout' => 10, // 连接超时时间(秒)
        'verify'          => true,      // 是否验证SSL证书
    ],

    // 打印机配置
    'drivers'    => [
        // 飞鹅云打印
        'feie'      => [
            'user' => '',  // 飞鹅云后台注册的账号
            'ukey' => '',  // 飞鹅云后台生成的UKEY
        ],

        // 易联云打印
        'yilian'    => [
            'client_id'     => '',  // 易联云应用ID
            'client_secret' => '', // 易联云应用密钥
        ],

        // 芯烨云打印
        'xpyun'     => [
            'user'     => '',     // 芯烨云账号
            'user_key' => '', // 芯烨云用户密钥
        ],

        // 快递100云打印
        'kuaidi100' => [
            'key'    => '',    // 快递100应用key
            'secret' => '', // 快递100应用密钥
        ],

        // 优声云打印
        'usheng'    => [
            'app_id'     => '',    // 优声云应用key
            'app_secret' => '', // 优声云应用密钥
        ],

        // 中午云打印
        'zhongwu'   => [
            'app_id'     => '',    // 中午云应用key
            'app_secret' => '', // 中午云应用密钥
        ],

        // 佳博云打印
        'poscom'    => [
            'api_key'     => '',         // 接口密钥
            'member_code' => '',      // 商户编码
        ],

        // 映美云打印
        'jolimark'  => [
            'app_id'     => '',     // 映美云应用ID
            'app_secret' => '', // 映美云应用密钥
        ],

        // 自定义驱动
        'custom'    => [
            'class' => '', // 驱动类的class, 须继承 Leapfu\CloudPrinter\Drivers\BaseDriver类,
            'key'    => '',    // 自定义应用key
            'secret' => '', // 自定义应用密钥
        ],
    ],
];
$printer = new CloudPrinter($config);
```

### 3. 打印文本（所有驱动统一 print 方法，参数为数组）

[](#3-打印文本所有驱动统一-print-方法参数为数组)

```
// 使用默认打印机
$result = $printer->driver()->print([
    'content' => '测试内容',
    'sn' => '打印机SN',
    'copies' => 1
]);

// 指定打印机类型
$result = $printer->driver('feie')->print([
    'content' => '内容',
    'sn' => 'SN',
    'copies' => 1
]);

// 直接调用打印机方法（动态代理）
$result = $printer->print([
    'content' => '内容',
    'sn' => 'SN',
    'copies' => 1
]);

if ($result['success']) {
    echo '打印成功';
} else {
    echo '打印失败：' . $result['message'];
}
```

> 所有驱动都实现 print 方法，参数为数组（如 \['content' =&gt; '内容', 'sn' =&gt; 'SN', 'copies' =&gt; 1\]），返回统一格式。其他高级功能请查阅对应驱动扩展方法文档。

---

框架集成用法
------

[](#框架集成用法)

### Laravel 集成

[](#laravel-集成)

1. **自动注册**（支持 Laravel Package Discovery，无需手动配置）
2. **发布配置文件（可选）**

    ```
    php artisan vendor:publish --provider="Leapfu\\CloudPrinter\\Laravel\\CloudPrinterServiceProvider" --tag=config
    ```
3. **门面调用**

    ```
    use CloudPrinter;
    CloudPrinter::driver()->print([
        'content' => '内容',
        'sn' => 'SN',
        'copies' => 1
    ]);
    ```
4. **容器调用**

    ```
    $printer = app(Leapfu\CloudPrinter\CloudPrinter::class);
    $printer->driver()->print([
        'content' => '内容',
        'sn' => 'SN',
        'copies' => 1
    ]);
    ```

### ThinkPHP 集成

[](#thinkphp-集成)

1. 在 `config/cloudprint.php` 配置参数。
2. 使用：

    ```
    app('cloud_printer')->driver()->print([
        'content' => '内容',
        'sn' => 'SN',
        'copies' => 1
    ]);
    ```

> 如需服务注册模板，可参考 `src/ThinkPHP/provider.php`。

---

安全性建议
-----

[](#安全性建议)

- 敏感信息建议通过 .env 或环境变量配置，不要硬编码在代码仓库。
- 日志中避免输出账号、密钥等敏感数据。

---

贡献与支持
-----

[](#贡献与支持)

- 欢迎提交 PR 或 Issue 参与共建！
- 如需更多示例或遇到问题，欢迎提交 Issue。

---

获取帮助与联系方式
---------

[](#获取帮助与联系方式)

- 📧
- 🐧 QQ 群：824070084（备注"云打印 SDK"）
- 🌐 官网：
- 📝 Issue 反馈：[GitHub Issues](https://github.com/leapfu/cloud-printer/issues)

如有商务合作、定制开发、技术支持等需求，欢迎通过以上方式联系我们。

---

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance49

Moderate activity, may be stable

Popularity32

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

371d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/128995ab9f01e04e321628bf6ba91f5b4fbaa0c0d186ba663ad1121696249e11?d=identicon)[leapfu](/maintainers/leapfu)

---

Top Contributors

[![leapfu](https://avatars.githubusercontent.com/u/147601235?v=4)](https://github.com/leapfu "leapfu (8 commits)")

---

Tags

printerapilaravelsdkphp-sdkreceiptthinkphp快递100cloud-printerthermal-printer

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/leapfu-cloud-printer/health.svg)

```
[![Health](https://phpackages.com/badges/leapfu-cloud-printer/health.svg)](https://phpackages.com/packages/leapfu-cloud-printer)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
