Actually, you can use them together.
I would recommend PHP for HTML generation, users management and other ordinary tasks and NodeJS for the server side of chat itself (broadcasting messages between users in real time). It is much simplier to do many typical web things with PHP while NodeJS has a great power for real-time applications with web sockets (yes, you can use web sockets in PHP too, but it isn’t that simple).
I don’t think it’s simpler to do those things with PHP at all. (personal preference) It’s just as simple to use Node.js and if you’re building as a Single Page Application, then I find it to be much easier to build restful services in Node.js over PHP.
The main argument there is that PHP doesn’t need a template language so that you can mix business logic with your views. Where as there are plenty of good reasons to keep your business out of your views and is widely considered bad practice, even in PHP.
Okay, but I read that I can’t embed nodejs code into my php files. Imagine that there is a web page consists of different parts (content management, chat, feed), can I use nodejs for only chat part or do I have to convert all my project into node and have to use a template engine like Jade?
I want to use PHP for most of the time and I am thinking of using nodejs for chat feature of the website. Can I do something like that?
I’ve looked into those template engines but they look very ugly. (No offense)
No… not Node.js. The point of Node.js is that it’s ran on the server. You can use JavaScript in your HTML to talk to your Node.js server. Your HTML can be rendered by PHP or it can just be static .html files.
You can have Node.js and PHP running on the same server. They will just talk on different ports.
You don’t have to use Jade, I don’t really like it either. I prefer EJS, it’s more like traditional template engines.
It’s kinda complicated to me, so I’ll ask one more question.
So I don’t need to start from scratch, I can keep developing my website with PHP, all I need is to create a seperate nodejs application for chat module (or any realtime feature) and use javascript in my php file to talk to it when it’s needed, is that correct?
Nothing wrong at all. But PHP looks more “essential” for such kind of tasks. That is just my private opinion, not the final truth.
Why have you decided this is the main argument? I can’t see where author tells that. This is just one of arguments (not the best one, because I completely agree with your point about logic and view separation). Anyway, that article isn’t about “why PHP is better”, it’s about pros and cons of each tool.
Well, maybe not the main but one of the top and it seems to be a reoccurring theme throughout the post, since the author seems to think it’s OK. lol
Really, all the arguments are kind of weak on both ends. The only one that even make sense are “Simplicity”, “Complexity”, "Service calls are thinner ", “JSON”, and “Raw Speed”. The rest are either flat out wrong or don’t make sense. Mostly just wrong.