PHP code example of nessworthy / amphp-http-httplug

1. Go to this page and download the library: Download nessworthy/amphp-http-httplug library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nessworthy / amphp-http-httplug example snippets


// Implementations of request/response factory interfaces. Are not bundled with this package!
use Laminas\Diactoros\RequestFactory;
use Laminas\Diactoros\ResponseFactory;

use Amp\Http\Client\Psr7\PsrAdapter;
use Nessworthy\AmpHttpPlug\AmpHttpClientAdapter;

use Amp\Http\Client\HttpClientBuilder;

$httpClient = HttpClientBuilder::buildDefault();
$psrAdapter = new PsrAdapter(
    new RequestFactory,
    new ResponseFactory
);

// Implements async and non-async interfaces.
$adapter = new AmpHttpClientAdapter(
    $httpClient,
    $psrAdapter
);