Skip to content

php-http/react-adapter

Repository files navigation

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.

About

React HTTP Adapter

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 10

Languages