I have working PHP application. It allows user create private projects and invite others in it. Now, using node.js and socket.io, I want to make real-time comments, posts etc.
What is the best architecture?
I see two solutions now.
The first is:
- User sends AJAX query to PHP backend: http://example.com/comment_add.php?text=...
- comment_add.php adds comment to database and via AMPQ (or something better?) notifies node.js server which broadcasts comment to channel's subscribers.
The second is:
- User sends AJAX query to node.js server: http://example.com:3000/comment_add
- Node.js sends request to PHP backend (But how? And what about authorization?), receives response, and then broadcasts to channel's subscribers.
What is the best way? Is there another methods? How to implement this properly?