Examples menu

Game of Life multiplayer

Click the board to draw crosses in your colour and watch Conway's Game of Life evolve them, together with everyone else on the page. A server timer advances the board every 200 ms and broadcasts the ROUTE scope, with one shared render per tick.

Shared board via ROUTE scope: everyone on this page sees and edits the same 50×50 grid. Click to draw a cross pattern in your color.
200ms timer: a $app->setInterval() callback evolves the board every 200 milliseconds and broadcasts the route. With shareRender: true the board renders once per tick for all viewers.
2,500 divs, no problem: each tick sends all 2,500 cells as plain HTML. No diffing, no virtual DOM, no clever protocol. The "stupid" solution just works because Brotli compression over SSE is absurdly efficient: 18 seconds of continuous updates transferred only 58 KB over the wire from 15 MB of raw HTML, roughly 250× compression.
No canvas, no JS drawing: the grid is a flat CSS Grid of server-rendered <div> elements with color classes. Datastar morphs them in place. The entire rendering pipeline is PHP string concatenation.
Why this matters: frameworks that diff on the client or send fine-grained patches add complexity for marginal gains. SSE + Brotli makes the brute-force approach viable even at 5 fps with thousands of elements, which covers the vast majority of real-world UIs.
Color identity: each tab gets the next of six colors, so the crosses of different players usually look different.
Lazy timer: the timer skips its work while countClients() finds nobody on this page, on any worker. Re-open the page and the board resumes from where it left off.
Collaborative drawing: every click is an action that mutates the shared board, then broadcasts the result. Multiple users can sculpt patterns together in real time.
One worker: this demo keeps the board in PHP statics, which each worker holds on its own. See What stays per worker before you run it with withWorkerNum().

Click cells to draw patterns. Several people can draw at once. 0 connected.

Generation: 1

Actions

toggleRunning

Pauses or resumes the simulation timer.

reset

Clears the entire board and resets generation counter.

tapCell

Draws a cross pattern at the tapped cell in the tab's color, and resumes a paused board.

Views

game_of_life.html.twig

ROUTE-scoped. 2,500 divs in a CSS Grid, re-rendered every 200ms by server timer. No canvas, no JS drawing.