# HyperfApiClient **Repository Path**: khyyyzd/hyperf-api-client ## Basic Information - **Project Name**: HyperfApiClient - **Description**: hyperf2.2 安全校验加密 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-11-21 - **Last Updated**: 2025-12-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Hyperf API Client Hyperf 分布式项目 API 客户端封装包。 ## 安装 ```shell composer require khyzd/hyperf-api-client ``` ## 说明 ### 发布配置文件 ```shell php bin/hyperf.php vendor:publish khyzd/hyperf-api-client ``` ### 使用 ```php apiClient->postJson('/test2', [['id' => 10, 'name' => '张三']]); var_dump($response); } catch (\Exception $e) { var_dump($e->getCode()); var_dump($e->getMessage()); } } /** * 回调函数 方式1 * */ public function index1() { //验证IP白名单 if(!$this->apiClient->verifyIpWhitelist()){ return $this->apiClient->errorResponse(500, 'IP地址不在白名单中'); } //验签 if(!$this->apiClient->verifyCurrentRequest()){ return $this->apiClient->errorResponse(500, '签名验证失败'); } //获取请求中的业务数据 $businessData = $this->apiClient->getBusinessDataFromRequest(); //处理业务逻辑 $result = [ ['id' => 10, 'name' => 'aaa'], ['id' => 11, 'name' => 'bbb'] ]; //成功响应 return $this->apiClient->successResponse($result); } /** * 回调函数 方式2 * */ public function index2() { return $this->apiClient->handleVerifyCurrentRequest( function (array $businessData) { //throw new \Exception('订单号不能为空', 440); //var_dump($businessData); $result = [ ['id' => 10, 'name' => 'ccc'], ['id' => 11, 'name' => 'ddd'] ]; return $result; } ); } } ```