定制 winglet/client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

winglet/client

Composer 安装命令:

composer require winglet/client

包简介

Generic HTTP client infrastructure for Winglet and compatible microservices.

README 文档

README

winglet/client is the generic HTTP client infrastructure package for Winglet and compatible PHP microservice environments.

This package contains only the reusable technical client layer:

  • target configuration loading
  • authentication modes
  • token caching
  • retry and correlation-id middleware
  • PSR-7 / PSR-17 / PSR-18 compatible HTTP handling
  • optional Winglet bridge for reading config and inbound bearer tokens from a Winglet runtime

This package does not contain service-specific clients such as AuthClient or IdentityClient. Those should live in their own packages and depend on winglet/client.

Included namespaces

  • Winglet\Client\Core\...
  • Winglet\Client\Bridge\Winglet\...

Typical usage

Generic client outside Winglet

use Winglet\Client\Core\Config\ArrayTargetConfigRepository;
use Winglet\Client\Core\Factory\ClientFactory;

$repo = new ArrayTargetConfigRepository([
    'billing' => [
        'base_url' => 'https://billing.example.test',
        'auth' => [
            'mode' => 'static_bearer',
            'static_bearer' => 'example-token',
        ],
    ],
]);

$factory = new ClientFactory($repo, __DIR__ . '/var/cache/clients');
$billing = $factory->create('billing');

$response = $billing->getJson('/status');

Generic client inside Winglet

use Winglet\Client\Bridge\Winglet\WingletClientFactory;

$factory = new WingletClientFactory($appContext);
$authClient = $factory->client('auth');
$result = $authClient->getJson('/authorization/effective?identityId=123');

Authentication modes

Supported auth.mode values:

  • none
  • static_bearer
  • service_token
  • identity_session
  • api_key
  • mtls

Service token authentication

service_token is the common machine-to-machine authentication mode for Winglet-based service clients. Service-specific clients do not need their own authentication implementation; they should create their underlying ServiceClient through ClientFactory and let this package fetch and cache the bearer token.

$repo = new ArrayTargetConfigRepository([
    'auth' => [
        'base_url' => 'https://auth.example.test/winglet/Auth',
        'auth' => [
            'mode' => 'service_token',
            'service_token' => [
                'token_url' => 'https://identity.example.test/winglet/Identity/auth/service-token',
                'client_id' => 'identity',
                'client_secret' => getenv('IDENTITY_AUTH_CLIENT_SECRET'),
            ],
        ],
    ],
]);

The token request sent to Identity is:

{
  "clientId": "identity",
  "clientSecret": "..."
}

The expected Identity response is:

{
  "accessToken": "eyJ...",
  "tokenType": "Bearer",
  "expiresIn": 3600,
  "expiresAt": "2026-07-04T09:30:00+03:00"
}

ClientFactory wraps the token provider in CachedTokenProvider, so the client reuses the token until shortly before expiry instead of authenticating on every request. The generated Authorization: Bearer ... header is applied by middleware and is invisible to service-specific clients.

Service-specific clients

Service-specific clients should be implemented in separate packages, for example:

  • winglet/auth-client
  • winglet/identity-client
  • winglet/subscription-client

A sample skeleton is included under examples/skeleton-client.

Development

composer install
composer run-script test

winglet/client 适用场景与选型建议

winglet/client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 64 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 winglet/client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 winglet/client 我们能提供哪些服务?
定制开发 / 二次开发

基于 winglet/client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 64
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 22
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2026-03-16