Skip to content

Latest commit

 

History

History
80 lines (50 loc) · 2.56 KB

README.md

File metadata and controls

80 lines (50 loc) · 2.56 KB

React adapter for PHP HTTP

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads

ReactHTTP adapter.

Install

Via Composer

$ composer require php-http/react-adapter

Features

This lib adapt ReactPHP behaviour to use the PSR7 interfaces. Also sync and async requests are possible without more code than a function call.

For a deeper async comprehension, you must check how ReactPHP engine work.

Usage

The Client class need a message factory in order to work:

$client = new Http\Adapter\React\Client($messageFactory);

For more control, it can also be configured with a specific React\EventLoop\LoopInterface and / or a specific React\HttpClient\Client:

$loop = Http\Adapter\React\ReactFactory::buildEventLoop();
$client = new Http\Adapter\React\Client($messageFactory, $loop);

//or

$reactClient = Http\Adapter\React\ReactFactory::buildHttpClient($loop);
$client = new Http\Adapter\React\Client(
    $messageFactory,
    $loop,
    $reactClient
);

If you don't want to use the Http\Adapter\React\ReactFactory to build instances you must rely on React documentation on Github: https://github.com/reactphp/http-client#example

Testing

First launch the http server:

$ ./vendor/bin/http_test_server > /dev/null 2>&1 &

Then the test suite:

$ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Security

If you discover any security related issues, please contact us at [email protected].

License

The MIT License (MIT). Please see License File for more information.