ocjojo/op-restclient
Composer 安装命令:
composer require ocjojo/op-restclient
包简介
A generic REST API client for PHP using objects to compose requests
README 文档
README
OOP - Object-oriented programming
PHP
REST-Client
A generic REST API client for PHP using objects to compose requests. This is based on and extends the excellent tcdent/php-restclient.
https://github.com/ocjojo/op-restclient (c) 2017 Lukas Ehnle me@ehnle.fyi
Installation
$ composer require ocjojo/op-restclient
Basic Usage
$api = new OPRestclient\Client([ 'base_url' => "https://jsonplaceholder.typicode.com" ]); // GET https://jsonplaceholder.typicode.com/posts/1?param_1=hello¶m_2=world $result = $api->posts->{1}->get([ 'param_1' => "hello", 'param_2' => "world" ]); if($result->info->http_code == 200) var_dump($result->decode_response());
Options for the client
See the documentation of tcdent/php-restclient for the configurable options. OPRestClient extends tcdent's RestClient, so all options and methods apply equally.
Standard Parameters
You are able to set standard parameters for consecutive requests to the same endpoint, e.g. if you want access data at an endpoint with paging. Like so:
$api = new OPRestClient\Client([ 'base_url' => "https://api.twitter.com/1.1", 'format' => "json", // https://dev.twitter.com/docs/auth/application-only-auth 'headers' => ['Authorization' => 'Bearer '.OAUTH_BEARER] ]); $api->search->tweets['q'] = '#php'; //both results will have the query parameter q set to '#php' $result = $api->search->tweets->get(['page' => '1']); $result2 = $api->search->tweets->get(['page' => '2']); // to delete a standard parameter of a route unset($api->search->tweets['q']); // to delete all standard parameters of a route $api->search->tweets->reset();
Standard Parameters will be set until you unset them manually.
ocjojo/op-restclient 适用场景与选型建议
ocjojo/op-restclient 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 20 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ocjojo/op-restclient 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ocjojo/op-restclient 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 20
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-09-02