This package is abandoned and no longer maintained. No replacement package was suggested.

Phergie plugin for Provide HTTP functionality to other plugins

4.1.0 2017-01-21 11:54 UTC

This package is auto-updated.

Last update: 2020-04-15 03:42:18 UTC


Phergie plugin for Provide HTTP functionality to other plugins.

Build Status


To install via Composer, use the command below, it will automatically detect the latest version and bind it with ~.

composer require phergie/phergie-irc-plugin-http 

See Phergie documentation for more information on installing and enabling plugins.


The HTTP plugin requires the DNS plugin to be setup for DNS resolving.


return [

    'plugins' => [

        // dependency
        new \Phergie\Plugin\Dns\Plugin, // Needed to do DNS lookups

        new \Phergie\Plugin\Http\Plugin([

            // All configuration is optional

            'dnsResolverEvent' => 'dns.resolver', // Event for retrieving the DNS resolver, defaults to 'dns.resolver'
            'guzzleClientOptions' => [], // Array with options passed into the Guzzle Client constructor (don't set a handler in here it will be overwritten)




Get Guzzle HTTP Client

$this->emitter->emit('http.client', [
    function (GuzzleHttp\Client $client) {
        // Make HTTP requests as documented on the Guzzle docs:
        // When making requests make sure to pass the future flag as documented:

Make a HTTP request

$this->emitter->emit('http.request', [new \Phergie\Plugin\Http\Request([
    'url' => '',                     // Required
    'resolveCallback' => function($response) { // Required
        // Data received do something with it
    'method' => 'GET',                                  // Optional, request method
    'headers' => array(),                               // Optional, headers for the request
    'body' => '',                                       // Optional, request body to write after the headers
    'rejectCallback' => function($error) {},            // Optional, callback that gets triggered on connection errors

A note about resolveCallback and rejectCallback. rejectCallback will only fire on a socket error. So resolveCallback will be called no matter what HTTP status code as the request has been successful on a connection level. Choosing the appropriate response to a status code is up to the event callee.


To run the unit test suite:

curl -s | php
php composer.phar install
cd tests


Released under the MIT License. See LICENSE.