enm/json-api-client-bundle

enm/json-api-client 的 Symfony 集成

5.0.0 2020-03-25 14:42 UTC

README

这是 enm/json-api-client 的 Symfony 集成。

  1. 安装
  2. 配置
  3. 使用

安装

composer require enm/json-api-client-bundle

建议安装 kriswallsmith/buzz 作为 http-client,以及 nyholm/psr7 用于 http 工厂。

composer require kriswallsmith/buzz nyholm/psr7

您也可以使用任何实现 PSR-18 的 HTTP 客户端。

配置

<?php
// config/bundles.php
    return [
        // ...
         Enm\Bundle\JsonApi\Client\EnmJsonApiClientBundle::class =>['all'=>true],
        // ...
    ];
enm_json_api_client:
    clients: # requires at least one element, the key will be your client name
        api: 'http://example.com/api'

使用

该包为每个配置的客户端提供了一个私有服务(仅用于依赖注入,不用于通过服务容器直接调用)。服务名称将为 enm.json_api_client.YOUR_CLIENT_NAME