innmind / rest-client
此包已废弃,不再维护。未建议替代包。
用于消费 REST API 的库
8.1.0
2021-02-14 10:51 UTC
Requires
- php: ~7.4|~8.0
- innmind/http: ~4.2
- innmind/immutable: ~3.5
- innmind/json: ^1.1
- innmind/operating-system: ~2.0
- innmind/specification: ~2.0
- innmind/url-resolver: ~4.0
- willdurand/negotiation: ~3.0
Requires (Dev)
- innmind/cli: ~2.0
- innmind/coding-standard: ^1.1
- innmind/object-graph: ~2.0
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~4.4
README
此库旨在消费使用 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 可用的所有资源。
然后您可以在任何服务器上访问以下方法: all
、read
、create
、update
和 remove
。查看 接口 以了解如何使用这些方法。