Reputation: 3801
I'm having a hard time figuring this out. I'm building a game and I want the game to be coded with Node.js (partly for learning and partly cause it seems right). But the game will also have a community and other stuff that will be in PHP.
So my question is. How do I talk to Node.js with PHP? Let' say that a user signs in and goes to the actual game (which is real time between to players), how do I give the user information to Node.js?
Or should I simply code everything with Node.js? I just want to be pushed in the right direction, what is the best way?
Upvotes: 0
Views: 455
Reputation: 732
You can try using JooDee, a node webserver which allows you to embed serverside javascript in your web pages. If you are familiar with Node and PHP/ASP, it is a breeze to create pages. Here's a sample of what a page looks like below:
<!DOCTYPE html>
<html>
<: //server side code in here
var os = require('os');
var hostname = os.hostname();
:>
<body>
<div>Your hostname is <::hostname:></div>
</body>
</html>
Using JooDee also lets you expose server javascript vars to the client with no effort by attaching attributes to the 'Client' object server side, and accessing the generated 'Client' object in your client side javascript.
https://github.com/BigIroh/JooDee
Upvotes: 0
Reputation: 3961
I'm not sure what you've tried, but since you question is pretty broad, try starting here: http://bergie.iki.fi/blog/dnode-make_php_and_node-js_talk_to_each_other/
Upvotes: 2