how do I invoke symfony"s doctrine service to operate the database within a socket service?
php website project done with symfony framework needs to use websocket service. The service written by socketio is started on the command line. Now it needs to query and save database operation in socket service. How should it be implemented?
the server program is as follows:
php
use Workerman\Worker;
use Workerman\WebServer;
use Workerman\Autoloader;
use PHPSocketIO\SocketIO;
require_once dirname(__DIR__,2)."/vendor/autoload.php";
$io = new SocketIO(2021);
$io->on("connection", function($socket) use($io) {
$socket->addedUser = false;
$socket->roleType = "";
var_dump("connection");
$socket->on("message", function($data) use($socket, $io) {
var_dump($data);
//
});
//
$socket->on("disconnect", function () use($socket, $io, $entityManager) {
var_dump("disconnect");
});
});
if (!defined("GLOBAL_START")) {
Worker::runAll();
}