Files
huangjingfen/pro_v3.5.1_副本/vendor/guzzlehttp/command/README.md

169 lines
5.9 KiB
Markdown
Raw Normal View History

feat(fsgx): 完成全部24项开发任务 Phase1-7 Phase1 后端核心: - 新增 fsgx_v1.sql 迁移脚本(is_queue_goods/frozen_points/available_points/no_assess) - SystemConfigServices 返佣设置扩展(周期人数/分档比例/范围/时机) - StoreOrderCreateServices 周期循环佣金计算 - StoreOrderTakeServices 佣金发放后同步冻结积分 - StoreProductServices/StoreProduct 保存 is_queue_goods Phase2 后端接口: - GET /api/hjf/brokerage/progress 佣金周期进度 - GET /api/hjf/assets/overview 资产总览 - HjfPointsServices 每日 frozen_points 0.4‰ 释放定时任务 - PUT /adminapi/hjf/member/{uid}/no_assess 不考核接口 - GET /adminapi/hjf/points/release_log 积分日志接口 Phase3 前端清理: - hjfCustom.js 路由精简(仅保留 points/log) - hjfQueue.js/hjfMember.js API 清理/重定向至 CRMEB 原生接口 - pages.json 公排→推荐佣金/佣金记录/佣金规则 Phase4-5 前端改造: - queue/status.vue 推荐佣金进度页整体重写 - 商品详情/订单确认/支付结果页文案与逻辑改造 - 个人中心/资产页/引导页/规则页文案改造 - HjfQueueProgress/HjfRefundNotice/HjfAssetCard 组件改造 - 推广中心嵌入佣金进度摘要 - hjfMockData.js 全量更新(公排字段→佣金字段) Phase6 Admin 增强: - 用户列表新增 frozen_points/available_points 列及不考核操作按钮 - hjfPoints.js USE_MOCK=false 对接真实积分日志接口 Phase7 配置文档: - docs/fsgx-phase7-config-checklist.md 后台配置与全链路验收清单 Made-with: Cursor
2026-03-23 22:32:19 +08:00
# Guzzle Commands
This library uses Guzzle and provides the foundations to create fully-featured
web service clients by abstracting Guzzle HTTP *requests* and *responses* into
higher-level *commands* and *results*. A *middleware* system, analogous to, but
separate from, the one in the HTTP layer may be used to customize client
behavior when preparing commands into requests and processing responses into
results.
### Commands
Key-value pair objects representing an operation of a web service. Commands
have a name and a set of parameters.
### Results
Key-value pair objects representing the processed result of executing an
operation of a web service.
## Installing
This project can be installed using [Composer](https://getcomposer.org/):
```
composer require guzzlehttp/command
```
## Service Clients
Service Clients are web service clients that implement the
`GuzzleHttp\Command\ServiceClientInterface` and use an underlying Guzzle HTTP
client (`GuzzleHttp\ClientInterface`) to communicate with the service. Service
clients create and execute *commands* (`GuzzleHttp\Command\CommandInterface`),
which encapsulate operations within the web service, including the operation
name and parameters. This library provides a generic implementation of a service
client: the `GuzzleHttp\Command\ServiceClient` class.
## Instantiating a Service Client
The provided service client implementation (`GuzzleHttp\Command\ServiceClient`)
can be instantiated by providing the following arguments:
1. A fully-configured Guzzle HTTP client that will be used to perform the
underlying HTTP requests. That is, an instance of an object implementing
`GuzzleHttp\ClientInterface` such as `new GuzzleHttp\Client()`.
1. A callable that transforms a Command into a Request. The function should
accept a `GuzzleHttp\Command\CommandInterface` object and return a
`Psr\Http\Message\RequestInterface` object.
1. A callable that transforms a Response into a Result. The function should
accept a `Psr\Http\Message\ResponseInterface` object and optionally a
`Psr\Http\Message\RequestInterface` object, and return a
`GuzzleHttp\Command\ResultInterface` object.
1. Optionally, a Guzzle HandlerStack (`GuzzleHttp\HandlerStack`), which can be
used to add command-level middleware to the service client.
Below is an example configured to send and receive JSON payloads:
```php
use GuzzleHttp\Command\CommandInterface;
use GuzzleHttp\Command\Result;
use GuzzleHttp\Command\ResultInterface;
use GuzzleHttp\Command\ServiceClient;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\UriTemplate\UriTemplate;
use GuzzleHttp\Utils;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
$client = new ServiceClient(
new HttpClient(),
function (CommandInterface $command): RequestInterface {
return new Request(
'POST',
UriTemplate::expand('/{command}', ['command' => $command->getName()]),
['Accept' => 'application/json', 'Content-Type' => 'application/json'],
Utils::jsonEncode($command->toArray())
);
},
function (ResponseInterface $response, RequestInterface $request): ResultInterface {
return new Result(
Utils::jsonDecode((string) $response->getBody(), true)
);
}
);
```
## Executing Commands
Service clients create command objects using the ``getCommand()`` method.
```php
$commandName = 'foo';
$arguments = ['baz' => 'bar'];
$command = $client->getCommand($commandName, $arguments);
```
After creating a command, you may execute the command using the `execute()`
method of the client.
```php
$result = $client->execute($command);
```
The result of executing a command will be an instance of an object implementing
`GuzzleHttp\Command\ResultInterface`. Result objects are `ArrayAccess`-ible and
contain the data parsed from HTTP response.
Service clients have magic methods that act as shortcuts to executing commands
by name without having to create the ``Command`` object in a separate step
before executing it.
```php
$result = $client->foo(['baz' => 'bar']);
```
## Asynchronous Commands
@TODO Add documentation
* ``-Async`` suffix for client methods
* Promises
```php
// Create and execute an asynchronous command.
$command = $command = $client->getCommand('foo', ['baz' => 'bar']);
$promise = $client->executeAsync($command);
// Use asynchronous commands with magic methods.
$promise = $client->fooAsync(['baz' => 'bar']);
```
@TODO Add documentation
* ``wait()``-ing on promises.
```php
$result = $promise->wait();
echo $result['fizz']; //> 'buzz'
```
## Concurrent Requests
@TODO Add documentation
* ``executeAll()``
* ``executeAllAsync()``.
* Options (``fulfilled``, ``rejected``, ``concurrency``)
## Middleware: Extending the Client
Middleware can be added to the service client or underlying HTTP client to
implement additional behavior and customize the ``Command``-to-``Result`` and
``Request``-to-``Response`` lifecycles, respectively.
## Security
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/command/security/policy) for more information.
## License
Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
## For Enterprise
Available as part of the Tidelift Subscription
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-command?utm_source=packagist-guzzlehttp-command&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)