soltancode/send-request
Composer 安装命令:
composer require soltancode/send-request
包简介
Simple package for Laravel that makes it easy to send HTTP requests and integrate with web APIs.
README 文档
README
Simple package for Laravel Framework that makes it easy to send HTTP requests and integrate with web APIs.
Installation
composer require soltancode/send-request
Usage
If you use it as class (facade), import this:
use Soltancode\SendRequest\Facades\SendRequest;
GET Request:
// $baseUrl = "https://dummyjson.com"; // $service = "/products/1"; # Using as class: SendRequest::get($baseUrl, $service); # Using as helper: sendRequest()->get($baseUrl, $service)
GET Request with params:
// $baseUrl = "https://dummyjson.com"; // $service = "/products/1"; // $params = [ // 'q' => 'phone' // ]; # Using as class: SendRequest::get($baseUrl, $service, $params); # https://dummyjson.com/products/search?q=phone # Using as helper: sendRequest()->get($baseUrl, $service, $params); # https://dummyjson.com/products/search?q=phone
POST Request with params:
// $baseUrl = "https://api.example.com"; // $service = "/login"; # Using as class: SendRequest::post($baseUrl, $service, [ 'username' => 'myusername', 'password' => 'mypassword' ]); # Using as helper: sendRequest()->post($baseUrl, $service, [ 'username' => 'myusername', 'password' => 'mypassword' ]);
PUT Request with params:
// $baseUrl = "https://api.example.com"; // $service = "/users/1"; # Using as class: SendRequest::put($baseUrl, $service, [ 'first_name' => 'John', 'last_name' => 'Doe' ]); # Using as helper: sendRequest()->put($baseUrl, $service, [ 'first_name' => 'John', 'last_name' => 'Doe' ]);
PATCH Request with params:
// $baseUrl = "https://api.example.com"; // $service = "/users/1"; # Using as class: SendRequest::patch($baseUrl, $service, [ 'first_name' => 'John' ]); # Using as helper: sendRequest()->patch($baseUrl, $service, [ 'first_name' => 'John' ]);
DELETE Request with params:
// $baseUrl = "https://api.example.com"; // $service = "/users"; # Using as class: SendRequest::delete($baseUrl, $service, [ 'id' => 'John' ]); # Using as helper: sendRequest()->delete($baseUrl, $service, [ 'id' => 'John' ]);
Timeout
The timeout method may be used to specify the maximum number of seconds to wait for a response:
$response = sendRequest()->timeout(3)->post(/* ... */);
Other Packages
ReturnResponse - It's a return helper for showing standard json responses.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
soltancode/send-request 适用场景与选型建议
soltancode/send-request 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.55k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「curl」 「json」 「rest」 「api」 「Guzzle」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 soltancode/send-request 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 soltancode/send-request 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 soltancode/send-request 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
Simple cURL wrapper
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
A fluent PHP CURL wrapper
统计信息
- 总下载量: 2.55k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-21