melonsmasher / ethos-php
一个用于与Ellucian Ethos API交互的PHP库。
v0.1.2
2021-04-29 16:20 UTC
Requires
- php: >=7.2.0
- ext-json: *
- guzzlehttp/guzzle: ~7.0
- myclabs/php-enum: ^1.8
README
一个用于与Ellucian Ethos API交互的PHP库。
安装
composer require melonsmasher/ethos-php
API 文档
完整的API文档可以在这里找到。
功能
目前,ethos-php
支持了 316
个模型/路由。它支持以下功能集的几乎所有Banner & Colleague模型。
-
支持方法链的流畅API,以增强可读性。
-
方便的方法,将响应数据返回为对象:
data()
,数组:toArray()
,和JSON字符串:toJson()
。 -
简单的API分页控制。每页最多返回十个项目。
-
会话过期时自动重新认证。
-
支持Banner和Colleague后端。
-
自动版本化的API调用。
-
对请求参数和头的控制。
-
类级别对Ethos CRUD支持的意识。
-
支持基于ID的路由。例如:
/api/persons/35b16136-bafd-4b5d-9dd2-995ad9f4ba00
-
支持
/consume
订阅消息队列路由。
即将到来的功能
- 支持
/publish
订阅消息队列路由。
用法/示例
以下示例演示了流畅API、便利方法和分页控制。
<?php include_once 'vendor/autoload.php'; use MelonSmasher\EthosPHP\EthosClient; use MelonSmasher\EthosPHP\Foundation\PersonsClient; // Your API Key / Refresh Token $secret = 'YourApiKey/RefreshToken'; // Create an authenticated Ethos session $ethos = EthosClient::createSession($secret); // Create a new Persons client using your Ethos session $personsClient = new PersonsClient($ethos); // Read the first page of persons $page1 = $personsClient->read()->data(); // Move to the next page $personsClient->nextPage(); // Read the second page $page2 = $personsClient->read()->data(); // Set the page to the fourth page $personsClient->setPage(4); // Read the 4th page to an array $page4 = $personsClient->read()->toArray(); // Move 1 page back to the 3rd $personsClient->backPage(); // Read the 3rd page to a JSON string $page3 = $personsClient->read()->toJson(); // Skip to the 6th page $personsClient->nextPage(4); // Read the 7th page $page7 = $personsClient->read()->data(); // Skip back to the 5th page $personsClient->backPage(2); // Read the 5th page $page5 = $personsClient->read()->data();
以下示例演示了提供自定义请求参数的能力。
<?php include_once 'vendor/autoload.php'; use MelonSmasher\EthosPHP\EthosClient; use MelonSmasher\EthosPHP\Foundation\PersonsClient; // Your API Key / Refresh Token $secret = 'YourApiKey/RefreshToken'; // Create an authenticated Ethos session $ethos = EthosClient::createSession($secret); // Create a new Persons client using your Ethos session $personsClient = new PersonsClient($ethos); // Send a request with the `criteria` parameter filtering for a person with a colleaguePersonId of 9000001. $data = $personsClient->read([ 'criteria' => '{"credentials":[{"type":"colleaguePersonId","value":"9000001"}]}' ])->data();
开发设置
安装 PHIVE
安装构建工具
phive install
安装composer依赖
./composer install