Examples menu

๐Ÿ”จ Live Auction

A timed auction with anti-snipe protection. Place a bid โ€” the server clock, bid history, and winner banner update for every viewer in real time.

Server-side countdown โ€” the clock is an OpenSwoole Timer::tick() that decrements on the server every second and broadcasts to all viewers. No client-side drift, no JS timers.
Anti-snipe protection โ€” if a bid arrives with fewer than 30 seconds remaining, the clock resets to 30s. Classic auction UX, implemented in four lines of PHP.
GLOBAL scope broadcasts every state change (bids, clock, sold status) to every connected viewer simultaneously, regardless of which tab or session they are on.
SESSION-scoped username persists across page refreshes and new tabs, giving each bidder a consistent identity throughout the auction lifecycle.
Lazy timer โ€” the countdown only runs while at least one viewer is connected. Zero viewers means zero CPU cost; the auction resumes from saved state when someone reconnects.
Full auction lifecycle โ€” active bidding, sold state with winner banner, and a reset action to restart the auction. All state transitions happen in PHP with no client logic.
๐Ÿบ

Ancient Roman Amphora

A remarkably preserved 1st-century terracotta storage jar, excavated near Pompeii. Museum provenance, authenticated.

Estimate: $75 โ€“ $200
๐Ÿ”จ

SOLD!

Won by KeenLynx for $60

Bid history

  • KeenLynx $60 01:48:10

โšก Signals

username string SESSION

Bidder identity, auto-assigned on first visit. Persists across tabs and refreshes.

bidInput string TAB

Draft bid amount. Private to this tab โ€” not broadcast.

๐ŸŽฏ Actions

placeBid

Validates bid > current top, updates top bid/bidder, resets clock if anti-snipe triggered, broadcasts to all viewers.

resetAuction

Restarts auction: resets clock, clears bids, sets status back to active. Useful for demo looping.

๐Ÿ‘ Views

live_auction.html.twig

Item card, live clock, top bid panel, bid history, and bid form. Full re-render on each broadcast via block: demo.