Skip to content

Latest commit

 

History

History
42 lines (30 loc) · 960 Bytes

README.md

File metadata and controls

42 lines (30 loc) · 960 Bytes

RESTer

RESTer 是一個方便呼叫 REST API 的函式庫。它可以使用已經建好的 ResterClient class ,也可以自行組合內部各種元件,成為一個客製化的 SDK 。

快速開始

使用 Composer 將套件加入

$ composer require 104corp/rester 

接著使用 ResterClient

use Corp104\Rester\ResterClient;
use Corp104\Rester\Api\Path;

// 初始化 ResterClient 物件
$resterClient = new ResterClient('http://127.0.0.1');
$resterClient->provisionMapping([
    'foo' => new Path('GET', '/foo'),
]);

// GET http://127.0.0.1/foo
$response = $resterClient->foo();

// PSR-7 Response
echo (string)$response->getBody();

接著就能看得到 response 的內容。

了解更多