nadar/yii-rest-client
Composer 安装命令:
composer require nadar/yii-rest-client
包简介
A Yii Framework Component in order to work with the LUYA headless REST Client. The LUYA REST Client is an Active Record similar solution for REST Clients.
README 文档
README
A Yii Framework Component in order to work with the LUYA headless REST Client. The LUYA REST Client is an Active Record similar solution for APIs.
It works with Yii Framework out of the box, therefore those things are included:
- Use
fieldsin your requests - Use
sortin your requests - Working with
expand - Caching
- CRUD (Create new records, Read records, Update records, Delete records) API operations
- Similar to Yii Framework Active Query and Active Record
Installation
Installation via composer
composer require nadar/yii-rest-client
Usage & Dokumentation
Configure your API Client:
'components' => [ 'api' => [ 'class' => 'Nadar\YiiRestClient\Api', 'server' => 'https://myapi.com', 'accessToken' => '...', ] ]
To see all LUYA Headless functions see the LUYA Headless Documentation
Now add your Rest Model (Active Endpoint), this represents the Model on the client side. It provides basic getter and setter methods same as Yii Framework.
class ApiCars extends \luya\headless\ActiveEdnpoint { public $id; public $name; public $year; public function getEndpointName() { return '{{%cars}}'; } }
The above example assumes the full endpoint is https://myapi.com/cars.
Working with the Model to make CRUD operations like list, edit, save.
Foreach Data (Will make a GET request):
foreach (ApiCars::find()->all(Yii::$app->api->client)->getModels() as $car) { var_dump($car->name); }
View One and Update the record (Will make a PUT request):
$car = ApiCars::viewOne(1, Yii::$app->api->client); echo $car->name; // f.e BMW $car->name = 'Mercedes'; $car->save(Yii::$app->api->client);
Add new entry (will make a POST request):
$car = new ApiCars(); $car->name = 'Honda'; $car->save(Yii::$app->api->client);
To see all LUYA Headless functions see the LUYA Headless Documentation
nadar/yii-rest-client 适用场景与选型建议
nadar/yii-rest-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.5k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 09 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nadar/yii-rest-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nadar/yii-rest-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-02