I'm trying to create a chat application using ratchet and php. I created websocket server to listen on port 8080 in server.php file but I can't find how run it parallel to the apache server after hosting.
server.php
<?php
require 'vendor/autoload.php';
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
use Ratchet\WebSocket\WsServer;
use Core\Socket\Chat;
use Core\Router;
use Core\Request;
$server = IoServer::factory(
new HttpServer(
new WsServer(
new Chat()
)
),
8080
);
$server->run();
index.php
<!DOCTYPE html>
<html>
<head>
<title>A Chat App</title>
</head>
<body>
<h1>Chat App</h1>
</body>
<script>
const socket = new WebSocket('ws://localhost:8080');
socket.addEventListener('open', event => {
console.log('Connection established');
socket.send('Hey There Everyone');
});
socket.addEventListener('message', message => {
console.log(message);
});
</script>
</html>
This works fine when I run server.php using cmd and index.php on localhost. But how to run these files in parallel after hosting on the web hosting service.