2017 © Pedro Peláez
 

library react-adapter

Adapter to make any ReactPHP library compatible with Amp.

image

amphp/react-adapter

Adapter to make any ReactPHP library compatible with Amp.

  • Wednesday, May 16, 2018
  • by kelunik
  • Repository
  • 3 Watchers
  • 11 Stars
  • 6,711 Installations
  • PHP
  • 6 Dependents
  • 0 Suggesters
  • 5 Forks
  • 3 Open issues
  • 3 Versions
  • 42 % Grown

The README.md

amphp/react-adapter

Stable License, (*1)

amphp/react-adapter makes any ReactPHP library compatible with Amp v2., (*2)

Note If you're using AMPHP v3, have a look at revolt/event-loop-adapter-react instead., (*3)

Installation

This package can be installed as a Composer dependency., (*4)

composer require amphp/react-adapter

Usage

Everywhere where a ReactPHP library requires an instance of LoopInterface, you pass ReactAdapter::get() to run the ReactPHP library on Amp's event loop., (*5)

<?php

require 'vendor/autoload.php';

use Amp\Loop;
use Amp\ReactAdapter\ReactAdapter;

Loop::run(function () {
    $app = function ($request, $response) {
        $response->writeHead(200, array('Content-Type' => 'text/plain'));
        $response->end("Hello World\n");
    };

    $socket = new React\Socket\Server(ReactAdapter::get());
    $http = new React\Http\Server($socket, ReactAdapter::get());

    $http->on('request', $app);
    echo "Server running at http://127.0.0.1:1337\n";

    $socket->listen(1337);
});

You can also use the adapter to run ReactPHP apps on an Amp event loop implementation without relying on Amp's global event loop., (*6)

$loop = new Amp\ReactAdapter\ReactAdapter((new Amp\Loop\DriverFactory)->create());

The Versions

16/05 2018

dev-master

9999999-dev

Adapter to make any ReactPHP library compatible with Amp.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/09 2017

v1.1.0

1.1.0.0

Adapter to make any ReactPHP library compatible with Amp.

  Sources   Download

MIT

The Requires

 

The Development Requires

15/06 2017

v1.0.0

1.0.0.0

Adapter to make any ReactPHP library compatible with Amp.

  Sources   Download

MIT

The Requires

 

The Development Requires