innmind/rest-client-bundle

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

用于消费REST API的库

4.0.0 2017-10-06 05:32 UTC

This package is auto-updated.

Last update: 2022-02-01 13:03:16 UTC


README

master develop
Scrutinizer Code Quality Scrutinizer Code Quality
Code Coverage Code Coverage
Build Status Build Status

安装

composer require innmind/rest-client-bundle

通过在项目的app/AppKernel.php中添加以下行来启用此包:

// app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Innmind\Rest\ClientBundle\InnmindRestClientBundle,
        );
        // ...
    }
    // ...
}

然后您需要指定应用程序中允许的类型,以下是一个示例:

innmind_rest_client:
    content_type:
        json:
            priority: 0
            media_types:
                application/json: 0

用法

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

此示例将返回通过http://example.com/ API提供的所有资源。

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