Skip to content

Instantly share code, notes, and snippets.

View clue's full-sized avatar

Christian Lück clue

View GitHub Profile
@clue
clue / 2018-05-17 introducing-ndjson-reactphp.md
Last active January 7, 2020 14:42
Introducing streaming newline-delimited JSON (NDJSON) with ReactPHP
@clue
clue / 2018-04-13 getting-started-with-reactphp-workshop-phpyorkshire.md
Last active December 16, 2023 12:33
Getting started with ReactPHP – Pushing real-time data to the browser (PHPYorkshire)

Think about "PHP" for a few seconds… What came to mind? It’s very likely you thought about your average product catalog, a blogging platform or how the platform is inferior to things like Node.js. But wait, it’s 2018! What if I told you PHP’s huge ecosystem has way more to offer and PHP is not inferior at all to its evil cousin Node.js?

Hands-on workshop given at PHPYorkshire (2018-04-13)

Getting started with ReactPHP – Pushing real-time data to the browser

In this hands-on tutorial you will learn about the core concepts of async PHP and why you too should care about ReactPHP being a real thing. The workshop has a strong focus on sparking the idea that PHP can be way faster and more versatile than you probably thought. Bring along an open mind and through lots of interesting examples and live demos learn why what sounds crazy at first might soon be a valuable addition in your toolbox.

You’re already familiar with PHP and want to learn what ReactPHP is all about? Then this tutorial is for you! We will

@clue
clue / gist:ed235ad8d50087d098e4de5fd370b25e
Created February 26, 2018 22:47 — forked from that0n3guy/gist:9754047
laptop routeprint and ipconfig all
C:\Users\lappy>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : lappy-PC
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
<?php
$loop = React\EventLoop\Factory::create();
$loop->addSignal(SIGINT, function () use ($loop) {
echo 'CTRL+C caught';
// cleanup...
// cleanup...
$loop->removeSignal(SIGINT);
});
$retry = function ($request, $next) {
return $next($request)->then(null, function ($error) use ($request, $next) {
// the $next failed. discard $error and retry once again:
return $next($request);
});
};
$runner = new MiddlewareRunner(array(
$retry,
function ($request, $next) {
@clue
clue / example.php
Created July 3, 2015 08:32
React\Promise\uncancellable()
$cancellable = new Promise(function () { }, function ($resolve, $reject) { $reject(); });
$uncancellable = uncancellable($cancellable);
assertPending($cancellable);
assertPending($uncancellable);
// this is a NO-OP
$uncancellable->cancel();
assertPending($cancellable);
assertPending($uncancellable);