Menu

WebSockets in PHP: what do you think about this approach?

#php#redditr#websocket#websockets#settings
Reading 0:00
15s threshold

Hello everyone,

I'm curious what PHP developers think about a different way to use WebSockets from scripts.

Imagine requesting (e.g. GET):

new WebSocket("ws://device.local/settings.php?key=value");

The server handles the WebSocket upgrade and then executes settings .php as regular PHP script, but with its IO redirected through WebSocket framing:

STDIN reads incoming WebSocket data.

STDOUT and echo sends data back to the client.

No special WebSocket classes, event loops ,callbacks etc are required in the script. It just runs and communicates through its input/output streams (e.g. via fread() ), the server provides all necessary framing for wth ws:// protocol.

For some context: I am researching an alternative PHP-like language, mainly for embedded devices.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.