PHP websockets – Ratchet

Ratchet is a PHP library, helps create websocket server
unfortunately Ratchet websockets “Hello world” does not works for me
Here is working example

<?php
use Ratchet\WebSocket\WsServer;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use MyApp\Chat;
require __DIR__ . '/vendor/autoload.php';

$ws = new WsServer(new Chat());
$ws->disableVersion(0); // old, bad, protocol version

// Make sure you're running this as root
$server = IoServer::factory(new HttpServer($ws),8080);
$server->run();
Profile photo of tyatin

tyatin Author

Leave a Reply