-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.php
More file actions
24 lines (17 loc) · 720 Bytes
/
Copy pathserver.php
File metadata and controls
24 lines (17 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare(strict_types=1);
require __DIR__ . '/../bootstrap.php';
use Micilini\PhpSockets\Chat\ChatServer;
use Micilini\PhpSockets\Config\ChatConfig;
use Micilini\PhpSockets\Config\ServerConfig;
$host = getenv('PHPSOCKETS_HOST') ?: '127.0.0.1';
$port = (int) (getenv('PHPSOCKETS_PORT') ?: 8080);
$publicPath = str_replace('\\', '/', __DIR__ . '/public');
echo "PHPSockets EasyChat server running on ws://{$host}:{$port}\n";
echo "Open the browser UI with: php -S 127.0.0.1:8000 -t {$publicPath}\n";
echo "Press Ctrl+C to stop the WebSocket server.\n\n";
$server = ChatServer::create(
ServerConfig::new(host: $host, port: $port, maxPayloadBytes: 4 * 1024 * 1024),
ChatConfig::new(),
);
$server->run();