I'm trying to expand an existing Webpage (NGINX + PHP5 + MySQL) with a real time API that feeds some additional data (for example, an in-page chat).
After going trough some standalone testscripts, etc, I'm actually already having troubles just to set up a simple chat example: Socket.io doesnt want to work, apparently because of dependencies.
I'm trying to use NodeJS/Socket.io only as alternative to fdajax - I never intended to build my whole (already existing) page on nodejs. So, my main question is, how can I 'implement' those two libraries, and still make them work (even if socket.io.js
isnt delivered by nodejs
)
My current error is ReferenceError: require is not defined
and ReferenceError: io is not defined
when including socket.io.js
. Apparently, the reason is that the function require()
probably doesnt work properly, since - well, nodejs isnt delivering the whole page, but PHP does (so, I guess, the whole require() stuff is missing).
Does someone know how I can get socket.io
to work, whitout having nodejs deliver the whole page, but instead still using the already existing NGINX+PHP setup?
I tried a couple of things, but couldnt find a good hint yet. The target basically is, to just include socket.io.js
(and other required stuff), connect to the nodejs webserver over the specified port (8080, or whatever), and then write some code.
Thanks for the help.