3

I want to write a simple chat application (for test use).

The users and messages are getting persisted in MongoDB, the session are getting stored with Redis.

The PHP (Symfony2) is providing authentication, registration, passwort reset, etc. and serves the public site (like /, /contact, etc.).

When the user has logged it has controll to the chat application. Backbone.js handles the application and node.js provides the data through rest (or socket.io).

Should I use either PHP and Node sidebyside or should I only use node?

The pro of only using node would be that there are no port collisions the contra is that the node app gets quite big and not so readable (IMHO: cmf, registration, authorisation, email handling would be easier to do with symfony than node)

2
  • you do not want to bind 2 services with same ip:port, apache runs at 80,8080 and can be changed to whatever you want, and if i remember correctly you can specify at node.js which port you want to use, so say apache is localhost:9999 and node.js at localhost:8888 no collisions..
    – Gntem
    Jun 23, 2012 at 12:39
  • You have to mention that the url still has to be readable. But indirectly you answered the question. So backbone.js or node.js can operate on different ports. What about the integration of both services (node.js and symfony) is there something like a best practise?
    – dev.pus
    Jun 23, 2012 at 14:24

2 Answers 2

4

It totally makes sense to keep your web application logic in PHP. That's what PHP is good at, and porting it to node.js code would probably be a wasteful and painful experience.

Node on the other hand is good at networking and serving long-running connections, such as WebSockets (socket.io, SockJS, etc.). So having a chat server using that also makes sense.

I suggest you use both, since each one of them solves a specific problem that it's good at. You can easily connect them using some kind of message queue.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.