reinfi/zf-guzzle-emitter

一个通过配置添加订阅者到 guzzle 发射器的 Zend Framework 模块。

1.0.0 2017-08-29 19:57 UTC

This package is auto-updated.

Last update: 2024-09-10 05:51:11 UTC


README

Build Status Code Climate Coverage Status

通过配置配置 guzzle 发射器订阅者。

  1. 安装
  2. 使用

安装

  1. 使用 Composer 安装: composer require reinfi/zf-guzzle-emitter
  2. 通过在 appliation.config.php 中的 modules 键启用模块
    return [
        'modules' => [
            'Reinfi\GuzzleEmitter',
            // other modules
        ],
    ];

使用

要使用它,您需要在以下配置键下注册您的订阅者。

'guzzle_emitter' => [
    'subscriber' => [
        YourSubscriber::class,
    ],
]

所有订阅者都必须在服务定位器内注册。

当您需要获取一个新的 guzzle 客户端时,只需传递以下选项

$options = [
    'emitter' => $container->get(\Reinfi\GuzzleEmitter\Emitter::class);,
    '...'     => '',
];

$client = new Client($options);

有关如何编写订阅者的信息,请参阅 http://docs.guzzlephp.org/en/5.3/events.html#event-subscribers

常见问题解答

随时提问或提交自己的拉取请求。