booosta/rest
Composer 安装命令:
composer require booosta/rest
包简介
REST API client for the Booosta Framework
README 文档
README
This modules provides a REST client for PHP Booosta to send REST requests to a server.
Booosta allows to develop PHP web applications quick. It is mainly designed for small web applications. It does not provide a strict MVC distinction. Although the MVC concepts influence the framework. Templates, data objects can be seen as the Vs and Ms of MVC.
Up to version 3 Booosta was available at Sourceforge: https://sourceforge.net/projects/booosta/ From version 4 on it resides on Github and is available from Packagist under booosta/booosta .
Installation
This module can be used inside the Booosta framework. If you want to do so, install the framework first. See the installation instructions for accomplishing this. If your Booosta is installed, you can install this module.
You also can use this module in your standalone PHP scripts. In both cases you install it with:
composer require booosta/rest
Usage in the Booosta framework
To use the REST functions, extend the Application object:
class MyREST extends \booosta\rest\Application
{
protected $url = 'https://api.football-data.org/v4/';
public function run()
{
// the following requests https://api.football-data.org/v4/competitions
return $this->get('competitions');
}
}
To use this class in the Booosta Framework do:
$rest = $this->makeInstance('MyREST');
print_r($rest->run());
Usage as standalone Module:
$rest = new MyREST();
print_r($rest->run());
Functions
// Submits a GET request to "$url$uri". If $raw is false, an array is returned, otherwise the JSON code
$this->get($uri, $raw = false);
// As get, but uses "$uri" instead of "$url$uri" ($url is the protected class variable)
$this->get_url($uri, $raw = false);
// Submits a POST request. $data has to be an array
$this->post($uri, $data, $raw = false);
// Submits a PUT request.
$this->put($uri, $data, $raw = false);
// Submits a DELETE request
$this->delete($uri);
// Sets optional username and password in the request. Call this before submitting a request.
$this->set_credentials($username, $password);
Inside your functions (in the above expamle run()) you can manipulate the REST clients behaviour:
// Sets request headers. Array with header name in the key and header value in the value.
$this->headers = $my_header_array;
// Example:
$this->headers = ['Content-Type' => 'application/json'];
booosta/rest 适用场景与选型建议
booosta/rest 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 booosta/rest 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 booosta/rest 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 21
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0-only
- 更新时间: 2022-03-04