Answer the question
In order to leave comments, you need to log in
How to implement PHP + NodeJS + Socket.IO?
Prompt the correct algorithm for the task.
There is a site, the whole basis is written in php, it is given in a bunch of nginx + apache. When opening a site (php), you need to start a connection with nodejs + socket.io and update the data by events. I do not understand how to make a connection to update the data. This option only comes to mind to run nodejs + socket.io in an iframe in which all events are already sent to the parent.
Conditional code:
<html>
<body>
<h1>Апач создал html документ</h1>
<div>Тут много phpшного кода</div>
<div>Тут постоянно меняющие данные, которые должны меняться по событию socket.io: <span id="count">10</span>
</div>
<div id="chat">Тут может быть чат, сообщения которые тоже приходят от socket.io</div>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
Don't connect one to the other if you don't want to.
Write and run a websocket server on the node.
You do this with nginx and this server: https://www.nginx.com/blog/websocket-nginx/
Place the client on the page generated by PHP.
Session storage must be available for both technologies. For example Redis.
Feel free to delete Apache, it is not needed for any of the tasks you listed.
Not quite what was asked, but https://github.com/wandenberg/nginx-push-stream-module might be useful
In the php code, you connect the javascript client part, which contains the address and port from which to receive data, what to do with it and where to insert it. PHP also has socket support, if you are more accustomed to working with php, use it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question