Using the simple chat tutorial from the socket.io website I set up a server with nodejs and socket.io, but I wanted to be able to use it with my preexisting webpage, which has php in it and is therefor a .php file. When I changed the .html to .php I was not able to get the php file loaded like the html file does. I get: Error: ENOENT, stat '/index.php' Any ideas?
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.get('/', function(req, res){
res.sendfile('index.php');
});
io.on('connection', function(socket){
socket.on('chat message', function(msg){
io.emit('chat message', msg);
});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});