aronwu/restful
Composer 安装命令:
composer require aronwu/restful
包简介
A lightweight PHP Restful Client library
README 文档
README
RestfulClient是最轻量的Restful PHP 客户端库
如何导入
include '../src/Restful/Client.php';
include '../src/Restful/Exception.php';
class_alias('\Restful\Client', '\RestfulClient');
composer
{
"require": {
"aronwu/restful": "*"
}
}
配置HostAlias
$hostalias = [
'order' => 'https://orderapi.xxx.com/v1',
'product' => 'https://productapi.xxx.com/v1',
];
//设置HostAlias
\RestfulClient::hostalias($hostalias);
//可以随时切换到不同的api
//访问order
\RestfulClient::host('order')->...
//访问商品
\RestfulClient::host('proudct')->...
如何设置Http Basic Authorization
\RestfulClient::auth('username', 'token');
Restful动作
支持 GET, POST, PUT, DELETE,PATCH 五个http mothod
Restful请求路径
比如 GET /orders/{order_id}/weixinpay
\RestfulClient::host('order')->orders('{order_id}')->weixinpay()->get(
[
'order_id' => 123456,
'limit' => 0
]
);
每个//之间资源都可以作为方法名称调用,比如/orders/ 可以调用方法orders, 方法参数也作为访问的路径自动添加。
手动设置Restful请求路径
\RestfulClient::host('order')->path('/orders/{order_id}/weixinpay')->get(
[
'order_id' => 123456,
'limit' => 0
]
);
调用path方法手动设置请求路径。
设置POST、PUT请求数据格式
设置x-www-form-urlencoded和 json格式调用format方法,默认是json格式。
\RestfulClient::host('order')->orders()->format->('urlencode')->post(
[
'product_id' => 123456,
'order_count' => 2
]
);
aronwu/restful 适用场景与选型建议
aronwu/restful 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 07 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「curl」 「http」 「rest」 「api」 「restful」 「requests」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 aronwu/restful 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 aronwu/restful 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 aronwu/restful 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
repository php library
Simple cURL wrapper
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
A fluent PHP CURL wrapper
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-07-30