Add composer.json for Workerman and load vendor autoload in websocket server

This commit is contained in:
Hamza-Ayed
2026-08-27 00:35:35 +03:00
parent b00a16f32d
commit 0d5215befd
2 changed files with 22 additions and 2 deletions
+14
View File
@@ -0,0 +1,14 @@
{
"name": "saqel/backend",
"description": "Saqel Platform Backend Architecture with Workerman WebSocket Engine",
"type": "project",
"require": {
"php": ">=8.2",
"workerman/workerman": "^4.1"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
}
}
+8 -2
View File
@@ -7,6 +7,12 @@
* - 4041 : Internal HTTP Event Dispatcher for PHP Backend
*/
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require_once __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists(__DIR__ . '/vendor/autoload.php')) {
require_once __DIR__ . '/vendor/autoload.php';
}
use Workerman\Worker;
use Workerman\Connection\TcpConnection;
@@ -15,8 +21,8 @@ require_once __DIR__ . '/../app/Core/Security.php';
require_once __DIR__ . '/../app/Core/Database.php';
// 1. Initialize Public WebSocket Server
$wsPort = (int)(getenv('WS_PORT') ?: 4040);
$internalPort = (int)(getenv('WS_INTERNAL_PORT') ?: 4041);
$wsPort = (int)(getenv('WS_PORT') ?: 4240);
$internalPort = (int)(getenv('WS_INTERNAL_PORT') ?: 4241);
$wsWorker = new Worker("websocket://0.0.0.0:{$wsPort}");
$wsWorker->count = 1; // Single process for unified in-memory connection registry