PHPackages                             topphp/topphp-client - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. topphp/topphp-client

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

topphp/topphp-client
====================

客户端管理组件

v1.0.6(5y ago)11363MITPHPPHP ~7.2CI failing

Since Feb 23Pushed 5y ago1 watchersCompare

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

READMEChangelog (7)Dependencies (4)Versions (8)Used By (3)

topphp-client
=============

[](#topphp-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ae0f52c74a61961e9db29f01772b38ba685e4a7834a3d52453f28b289d9029e3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f707068702f636f6d706f6e656e742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/topphp/component-builder)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/005f716166c16d1e3c68f324454da4b8e9beb429be5097bd10b75455fb02117d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f707068702f636f6d706f6e656e742d6275696c6465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/topphp/component-builder)

> 这是一个客户端管理工具，包含Http请求客户端Guzzle，Redis客户端，Socket客户端等

包含方法
----

[](#包含方法)

- Http客户端请求 GET POST PUT PATCH DELETE
- Redis客户端 普通set get存取，list存取，哈希存取等

组件结构
----

[](#组件结构)

```
config/
src/
tests/
vendor/

```

安装
--

[](#安装)

```
    composer require topphp/topphp-client
```

用法
--

[](#用法)

```
    全客户端命名空间引用：
        use Topphp\TopphpClient\Client;
    Redis客户端助手类命名空间引用：
        use Topphp\TopphpClient\redis\RedisHelper;
    Http客户端助手类命名空间引用：
        use Topphp\TopphpClient\guzzle\HttpHelper;
    调用方式有两种：
        1、通过原始客户端单例调用指定的客户端
            Client::getInstance()->cli("redis")->set("arr", ["这是一个数组"], 90);
        2、通过助手类直接调用【推荐】
            RedisHelper::set("arr", ["这是一个数组"], 90);
            HttpHelper::get("https://www.baidu.com");
            $data = [
                "field"=>"val"
            ];
            // $type 类型：在header头为空的情况下，自动根据类型填充header头信息，包含（json，body，form_params，multipart，xml）
            HttpHelper::post(string $url, array $data, string $type = 'json', array $headers = [])
    注意事项：
        1、写好对应的配置后，在骨架即可直接调用，无需传入配置，需要动态切换配置时，只需要通过骨架的config()方法动态修改即可。
        2、还提供一种直接传入配置的方式
            Client::getInstance($config)->cli("http")->get("https://www.baidu.com");
        3、组价同时也提供直接暴露客户端对象句柄的方式直接调用原生客户端对象，完成更多高级操作
            Client::getInstance()->cli("redis")->handler()->publish( $channel, $message );
            RedisHelper::handler()->publish( $channel, $message );
        4、关于获取配置优先级顺序
            A.Client::getInstance($config)// 优先获取手动传入的配置（助手类不适用）
            B.非手动传入配置的（配置不传，传空或者使用助手类），优先根据指定客户端获取独立配置文件topphpClientHttp、topphpClientRedis、topphpClientSocket中的配置
            C.没有配置独立配置文件的Redis客户端会自动获取Cache配置中的redis配置
            D.都没有的，会提示配置错误
        5、独立配置文件示例：
            Http：暂无需配置，保持默认即可，swoole环境自动提供协程的http客户端
            Socket：敬请期待...
            Redis：swoole环境已内部集成协程化的Redis客户端

                return [
                    // 客户端连接方式配置
                    'Redis' => [
                        // 支持多库配置（默认选择default,可以通过修改默认的connect来动态切换redis配置）
                        'default_connect' => 'default',
                        'default'         => [
                            // 连接地址
                            'host'         => '127.0.0.1',
                            // 连接密码
                            'auth'         => '',
                            // 端口
                            'port'         => 6379,
                            // 选择库
                            'db'           => 0,
                        ]
                    ]
                ];

        6、默认的助手类已经提供了大部分常用场景所需的方法，更多用法可以参看单元测试文件和对应的官方文档
```

修改日志
----

[](#修改日志)

有关最近更改的内容的详细信息，请参阅更改日志（[CHANGELOG](CHANGELOG.md)）。

测试
--

[](#测试)

```
    ./vendor/bin/phpunit tests/ClientTest.php
```

贡献
--

[](#贡献)

详情请参阅贡献（[CONTRIBUTING](CONTRIBUTING.md)）和行为准则（[CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md)）。

安全
--

[](#安全)

如果您发现任何与安全相关的问题，请发送电子邮件至，而不要使用问题跟踪器。

信用
--

[](#信用)

- [topphp](https://github.com/topphp)
- [All Contributors](../../contributors)

许可证
---

[](#许可证)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.8% 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

Every ~35 days

Recently: every ~50 days

Total

7

Last Release

2057d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3774ddafd6cc1dbff3db41386611fac2236c095e12c9e99f1717da35ad792087?d=identicon)[topphp](/maintainers/topphp)

---

Top Contributors

[![344147805](https://avatars.githubusercontent.com/u/26813709?v=4)](https://github.com/344147805 "344147805 (22 commits)")[![go-sleep](https://avatars.githubusercontent.com/u/100214298?v=4)](https://github.com/go-sleep "go-sleep (10 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/topphp-topphp-client/health.svg)

```
[![Health](https://phpackages.com/badges/topphp-topphp-client/health.svg)](https://phpackages.com/packages/topphp-topphp-client)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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