Building Real-Time Apps Without a Framework

2026-07-08

I built Real-Time PHP to explore this question: when should you use a framework vs raw WebSockets?

The Framework Bias

Most tutorials jump straight to Socket.io, Laravel Echo, or SignalR. These are great for complex apps. But for simple real-time features, they add unnecessary complexity.

When Raw WebSockets Win

The Pattern

// Client
const ws = new WebSocket('ws://server:8080');
ws.onmessage = (event) => {
  updateDashboard(JSON.parse(event.data));
};
// Server (with Ratchet)
$loop->addPeriodicTimer(5, function() use ($clients) {
  $data = getLatestMetrics();
  foreach ($clients as $client) {
    $client->send(json_encode($data));
  }
});

The Trade-off

| Using a framework | Raw WebSockets |

|-------------------|----------------|

| Auto-reconnection | Manual reconnection |

| Room/channel management | Custom implementation |

| Fallback transport | Must handle yourself |

For Bubely's dashboard, I used periodic polling. It's simpler, works everywhere, and for a 5-second refresh interval, the overhead is negligible.

Don't add a framework until you need it. WebSocket is already in every browser.