You can't run two applications on the same port. The easiest thing to do is proxy HTTP requests to PHP, running on another port, and proxy other requests to Socket.IO, running on another port.
Here's an example using http-proxy. Do note that this won't work for things like flashsockets and XHR long polling.
var httpProxy = require('http-proxy')
var server = httpProxy.createServer(function (req, res, proxy) {
proxy.proxyRequest(req, res, {
host: 'localhost',
port: // whatever port PHP is running on
});
})
server.on('upgrade', function (req, socket, head) {
server.proxy.proxyWebSocketRequest(req, socket, head, {
host: 'localhost',
port: // whatever port Socket.IO is running on
});
});
server.listen(80);
Alternatively, you could route your Express routes to PHP. If PHP was running on port 8080 for example:
app.get('/', function(req, res) {
// send a HTTP get request
http.get({hostname: 'localhost', port: 8080, path:'/', function(res2) {
// pipe the response stream
res2.pipe(res);
}).on('error', function(err) {
console.log("Got error: " + err.message);
});
});