innmind/rest-server

此包已被放弃且不再维护。未建议替代包。

用于轻松暴露REST API的库

8.1.0 2021-02-13 15:00 UTC

README

Build Status codecov Type Coverage

此库包含一系列工具,用于通过HTTP以REST方式定义、验证、提取和暴露资源。

安装

通过composer

composer require innmind/rest-server

使用

use function Innmind\Rest\Server\bootstrap;
use Innmind\Rest\Server\Gateway;
use Innmind\Immutable\Map;

$services = bootstrap(
    new Map('string', Gateway::class),
    require '/path/to/resources/mapping.php'
);

$services['routes']; // provides all the routes available for the definitions you provided

// action controllers
$services['controller']['create'];
$services['controller']['index'];
$services['controller']['get'];
$services['controller']['remove'];
$services['controller']['update'];
$services['controller']['link'];
$services['controller']['unlink'];
// controller to output the resource definition
$services['controller']['options'];
// controller to expose links to all the resources definitions
$services['controller']['capabilities'];

网关是此组件与您的域之间的桥梁。处理哪个网关处理哪个资源的定义处理在资源映射中完成,其中资源只能由一个网关管理。请查看 fixtures/mapping.php 了解如何定义您的资源。