innmind/rest-client

此包已废弃,不再维护。未建议替代包。

用于消费 REST API 的库

8.1.0 2021-02-14 10:51 UTC

This package is auto-updated.

Last update: 2023-01-11 18:03:09 UTC


README

Build Status codecov Type Coverage

此库旨在消费使用 RestServer 构建的 API。

安装

composer require innmind/rest-client

使用

use Innmind\OperatingSystem\Factory;
use Innmind\Url\Path;
use Innmind\UrlResolver\UrlResolver;
use function Innmind\Rest\Client\bootstrap;

$os = Factory::build();
$client = bootstrap(
    $os->remote()->http(),
    new UrlResolver,
    $os->filesystem()->mount(Path::of('/somewhere/to/cache/data')),
);

$client
    ->server('http://example.com/')
    ->capabilities()
    ->names();

以下示例将返回通过 http://example.com/ API 可用的所有资源。

然后您可以在任何服务器上访问以下方法: allreadcreateupdateremove。查看 接口 以了解如何使用这些方法。

结构