apache - Adding Node.js (for real-time notifications) to an existing PHP application -
i have existing php application, need add realtime notifications. in order achieve have installed node.js (intending add socket.io real time functionality)
however. despite spending last 3 hours researching , trying head around how integrate two, have found myself no closer gaining understanding.
i using following:
- apache
- php
- nginx (as reverse proxy apache static content images/css files etc)
- mysql
i have code written sends event client php , inserts notification database. when recipient refreshes page of course see notification. need node.js handle real time pushing client @ loss how go setting up.
what need know, given scenario, following:
- how/when node.js/websocket connection client instantiated, given wish content still served via apache/php?
- how can send message php node.js , instruct push notification client?
- what kind of end modifications need make setup in order support this?
ultimately able run php function , expect node.js/socket.io/websockets push notification client. have no idea how there.
thanks in advance examples/information/guides.
what in scenario set node.js server socket.io. gives cross-browser method sending near-real-time data clients.
when client loads php page, have <script>
tag pointing @ node.js server load socket.io. once loaded, socket.io javascript client connect node.js socket.io server , wait events emitted.
now, since want these events sent php, need communication channel between php application , node.js. recommend using redis pub/sub this. basically, php application publishes message, , node.js servers have subscribed receive it. servers can pass message on client go more data php. (i think find though might easy have node.js server send data in first place.)
you can put node.js behind nginx server if want, but need latest , greatest version true web socket support.
Comments
Post a Comment