I am doing a start up and am figuring out my stack. I've been using php for around 5 years now and am extremely familiar with it. However, I've recently been introduced to node.js and have seen it is on the rise. I'm not sure what to use for server side.

The purpose of my company is e-commerce. Users will have accounts and subscribe to a service. I hope to grow quickly. Would node.js be a good choice or would php be fine?

Member Avatar for diafol

My experience with node was very mixed. I ended up scrapping the whole thing and throwing the laptop out of the window (proverbially of course). It's been touted as the next big thing or the new big thing. An interesting article:

http://www.sitepoint.com/sitepoint-smackdown-php-vs-node-js/

I don't particularly agree with every "round", but opinions are subjective after all.

IMO, either should be do-able, PHP or node. BUT - which will be best for you? Learning node will take some time, but may ultimately be worth it.

You could of course use both together!
http://stackoverflow.com/questions/9831594/apache-and-node-js-on-the-same-server

I respect any programming language , technique or environment (I am not sure how to state it in a way that node.js folks would accept it) . About node.js , there where few years in the web that node.js could make your life easier if you would like to programming something like a chat. Now days with WS (WebSockets) I can't understand why node.js is still around other than that some programmers have learned it (and I respect that , but please learn something newer also). It's strong points are not any more something that you can't do in PHP or Java in a more easy way , maybe one factor that node.js is still out-there is not only that few programmers hold in it but that the implementation of WS in PHP (or Java) is still not mature in common frameworks that spend a lot in advertising.

commented: +1 +14

Node.js is simply (AFAIK) a javascript API that allows you to speed up client-side development. Remember, JS runs on the client, and PHP on the server. PHP can serve up javascript to the client, where it is executed, and this includes node.js scripts. So, I don't think it is a matter of one vs. the other, but making them work well together. Keep server-side stuff on the server, and client-side stuff on the client. This sort of "separation of powers" will help with system security, as well as performance. In any case, use PHP on the server as the object-oriented language it was designed to be. Try not to mix HTML/JS with your PHP code, but rather use php to send the HTML and JS code to the client where it will be executed.

FWIW, this is the approach I used, with great success, at Nokia Mobile Phones before the Microsoft takeover.

rubberman I agree with you with the "separation of powers" as you described it , but just to be clear because others might read this , Node.js is an “Event-driven I/O server-side JavaScript environment” as itself is described.

commented: Good point. I try to leave JS off of the server as much as possible. +13

Web servers often have to service 1000's of users in a short period of time. The less code they have to run, the better. My philosophy is to push as much of the processing, especially for UI stuff, as possible to the client, and leave the server to handle database I/O, and generating the html/js code needed by the client , and then pushing that out to the client in as big of chunks as possible. Less network traffic that way, and the server can handle many more users without noticeable performance degredation. Remember that client systems can usually download data much faster, and with lower latency, than they can upload it, so the less the network I/O, especially with regard to client->server stuff, the better.

I've used both extensively.
NodeJS and PHP both run server side.

Relative Features of Node:
  • Typically run standalone without apache or nginx
  • Is not multi threaded, but is defaulted as async (which makes it non-blocking)
  • It's javascript syntax (the more complex the feature, the less built out it is)
  • A lot of devs get super excited, build a library, then don't keep up with the next flavor of node
  • npm is cool, until its not. It supports windows, but will break pathing after a while.
  • hasn't been used a lot in ecommerce server side environments
  • Make sure your Database has a module.
  • Make sure you figure out how you are going to keep it running (as a service / cronjob?)
Relative Features of PHP
  • Typically run behind apache or nginx (standalone is considered beta, not for production)
  • Is not multithreaded and a single process is blocking (apache/nginex spawn multiple processes). Additional ReactPHP.
  • Php syntax - just happens to be very clean.
  • Composer is cool.
  • much more mature in the e-commerce space.
  • Your database is probably supported

I personally prefer PHP - it's more mature and I like the syntax.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.