Skip to content

Instantly share code, notes, and snippets.

View kelunik's full-sized avatar

Niklas Keller kelunik

View GitHub Profile

test tab not enter

*test *tab* not enter*
<?php
use Amp\Beanstalk\BeanstalkClient;
use Amp\Loop;
require __DIR__ . "/vendor/autoload.php";
Loop::run(function () {
$uri = "udp://127.0.0.1:38925";
<?php
require __DIR__ . "/vendor/autoload.php";
use Amp\Promise;
$client = new Http\Adapter\Artax\Client;
$responses = Promise\wait(Promise\all([
$client->sendAsyncRequest($request1);
<?php
require __DIR__ . "/vendor/autoload.php";
use Amp\Promise;
$client = new Http\Adapter\Artax\Client;
$request1 = new GuzzleHttp\Psr7\Request("GET", "http://example.com/");
#!/bin/bash
set -e
set -x
rm -rf ~/.php-build
mkdir ~/.php-build
cd ~/.php-build
if [ $1 == "master" ]
@kelunik
kelunik / polygon.txt
Created February 20, 2018 10:12
Polygon Intersection
______
____/ \
/ \ |
| | /
\_____|____/

You can use amphp/react-adapter + amphp/amp, which will give you an ev based implementation – if ev is installed – that is fully compatible with ReactPHP's LoopInterface.

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

// $loop is now a ReactPHP compatible driver based on ext-ev

If you don't want the automatic driver selection based on the available extensions, you can also instantiate a driver on your own using $driver = new Amp\Loop\EvDriver;.

<?php
require __DIR__ . "/vendor/autoload.php";
$http = new Amp\Artax\Client;
$promises = [
async $http->request("https://google.com/"),
async $http->request("https://stackoverflow.com/"),
];
<?php
use Amp\Emitter;
use Amp\Iterator;
use Amp\Promise;
class CsvReader implements Iterator {
/** @var EventEmitter */
private $eventEmitter;
<?php
use Amp\Iterator;
use Amp\Cluster\Listener;
use Psr\Log\LoggerInterface as PsrLogger;
Amp\Loop::run(function () {
if (Amp\Cluster::isWorker()) {
$socket = yield Amp\Cluster::listen("tcp://0.0.0.0:8080");
$logger = Amp\Cluster::getLogger();