DEV Community

Cover image for PHP vs Node?
Muhammad
Muhammad

Posted on

PHP vs Node?

I have done quite many projects with clients in PHP, but now I have moved away from PHP to Node.

I would like to know what do you guys have to say about it.

My Opinion About PHP

It is a great powerful language to make your programming concepts very clear and how your code will translate, the language is based on original core concepts and as a beginner, i do highly recommend it.

Node

Very Fast, Highly performative, a bit complex for beginners, and it has its own new concepts to embark upon. It is a versatile language and i think the demand for todays market.

Latest comments (52)

Collapse
 
jdsllk7 profile image
Kosamu

I'm a 2 year old Node.js dev & a 5 year old Php dev. I think what makes a good programming language is it's ability to attract programmers & consequently make them stay.
That's Node.js for me.
Note: learning node.js from a php background is challenging @ first because it has somewhat completely new concepts but once you get the hang of it you'll realize there's a module for almost anything you want.

Collapse
 
akshatjen profile image
AJ

Any Go developers having a laugh here?? xD

Collapse
 
kalium profile image
kalium.xyz

Node is great for prototyping any type of application, PHP is great for templates.

You might have wrongly tagged this with #docker though its good advice to run your projects inside containers as there have been some trojans in NPM packages which won't be very effective when running in a container. if you use node please make sure you know who made your dependencies and transient dependencies, you are trusting them! Also always set your dependencies to fixed versions and use package-lock.json!

Collapse
 
donnisnoni profile image
Don Alfons Nisnoni • Edited

I agree with you... but i tired press $ on keyboard for variable... unless you...

and you got lot of discussion when you try make post about 'node vs php'

 
vicoerv profile image
Vico

hello, thank you for make it clear

as you can see here

<VirtualHost *:80>
    ProxyPreserveHost On

    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>

it only run one service, my company is SaaS so probably in one vps there will be tens of different project and to run different project with manual port handling will take more time

Collapse
 
muhamadzolfaghari profile image
muhamad zolfaghari • Edited

NodeJS. VS Poorly Heat Pattern!
Null or defines equal VS PHP

 
xowap profile image
Rémy 🤖

Oh well, I assumed that frameworks would make sure that req.param('name') is a valid unicode string while $_GET['name'] can be any string of bytes but maybe I'm expecting too much?

In any case, you can write stupid code in all languages. But to be specific to the $_GET issue, it's so easy to break encapsulation using it (because it's global). Same thing with $_REQUEST, what is the point of this except getting X-whatever-scripting attacks from all sides?

PHP is just next-level compared to anything else in terms of possible misuses.

 
th3n00bc0d3r profile image
Muhammad

Lolx rules are rules we didnt make em so we gotta follow em... I think what you might be embarking is creation if a new language above a language...

The evolution of assembly to java and beyond now

Thread Thread
 
xowap profile image
Rémy 🤖

Yes, although it's mostly a front-end issue. On the back-end if you try to access DB data in a non-async way you'll quickly realize that the data is simply not there. I've been handed large amounts of amateur JS and there was MANY issue but not really that one.

The kind of issues that PHP enables are more like "let's execute this unfiltered user input" which is way more dramatic than a randomly-bugged front-end component.

Collapse
 
th3n00bc0d3r profile image
Muhammad

I agree but what can you say... Its just how it goes and how it has gone with perception

 
th3n00bc0d3r profile image
Muhammad

Thanks for the response Jorge, i dorecommended pm2 because if the process fails of some error it just restarts it. Hope you'd agree

Collapse
 
vimmer9 profile image
Damir Franusic • Edited

I know I'm playing with fire here so please keep in mind that starting and endless discussion is not my intention.

I prefer PHP over Javascript. They are both programming languages and choosing one over the other is a mater of personal preference. People keep mentioning Node.js but that's a runtime for javascript with mod_php being the same equivalent for php interpreter in Apache. They are made for different purposes; Node.js apps are standalone apps which are better suited for persistent long lasting connections for example, while php is meant for exec-and-exit situations like single page renderings, etc. I have even written shell scripts in php just because syntax is more to my liking than bash.

You could also do a long running apps, persistent connections and numerous other insane endeavours with php, but maybe with a lot more effort than doing the same thing in Node.

Once again, I am not a fan of Javascript but have used it on both client (React) and server (Next). Beginners will for sure find asynchronous Node programming much harder than php. I don't understand how php syntax if more complicated than javascript 🤔

PHP is constantly being updated and has come a long way and although It's been a while since I last used it, I'm sure the security issues are much less frequent nowadays.

Maybe I'm just biased since php was my first web language, but it deserves some respect and it certainly doesn't deserve all the flame coming from javascript-only developers.

P.S.
Anyone remember Tomcat App Server? 😉

Collapse
 
shegunbabs profile image
Shegun Babs

I think the comparism isn't fair enough. PHP is a programming language while Node isn't. Node is a runtime environment to run Javascript on the backend. So any comparism between the two will be off context.
Each language has its strengths and weaknesses that is why I hate to compare languages.
If the language isn't relevant anymore then you won't find it around.

Collapse
 
peon501 profile image
Matas Lesinskas

Gosh. I would pick php at any time of day. Node.js isn't made for large projects...
Who think php is trash and insecure are just stupid and never learned how to work with php or any other server side lang.
Good luck with js back end.lol.
I cant read this comment section...

Collapse
 
charlesnjau profile image
CharlesNjau

Thank you very much for highlighting this

Collapse
 
marcus-sa profile image
Marcus S. Abildskov • Edited

Nodejs isn't made for large projects? Who are you kidding?
You just sound like my college who's afraid to learn something new because it goes beyond your area of expertise.
There's a reason mostly every company moves from PHP to Nodejs or .NET.
TS + Node is far superior than PHP.
github.com/nestjs/nest

Collapse
 
peon501 profile image
Matas Lesinskas

Btw I have basics with node.js socket.io and Iam quite good at net. I wrote realtime pos system on it, but I would not use node where I dont need(I mean execute exit process software).

Collapse
 
motss profile image
Rong Sen Ng

I still find setting up a PHP server not as easy and straightforward as a Node server. Is that true for most of you?

Collapse
 
anwar_nairi profile image
Anwar

Depends if you build it up from a bare nude OS or not. Anyway I never set up a NodeJS capable web server, only did it for PHP and it was as easy as chaining commands. Got my website up and running, set up some cron for my Laravel Queue jobs, just a breeze.

Also have the same experience with a Xampp local config (and thinking on switching to Docker containers for my next project).

Collapse
 
sonyarianto profile image
Sony AK

with help of Docker now this should be easy

Collapse
 
th3n00bc0d3r profile image
Muhammad

I think it really depends on what environment you are setting up. There are many scripts now written to single install all what you need, it does come with extra but you get past the headache.

Collapse
 
motss profile image
Rong Sen Ng

Cool. Thanks for the clarification.

Collapse
 
karlredman profile image
Karl N. Redman

PHP and Node attempt to solve the same problem from different points of view. PHP considers the server-first perspective while node considers the client-first perspective (generally speaking). Node has the advantage of having a larger common (COMMON) user base and the disadvantage of being a bigger target for abuse. PHP libs have been around a long time and are less likely to have new hacks against them but have a history of exploits because of managing applications.

Before I get flamed! ....

I agree that anything you want to do in php is also possible via node. Javascript is simply more popular in hireing circles etc. PHP is considered a downtrend technology because of it's limitations relative to (server side) python, etc. IMHO PHP perceived limitations don't make it better or worse than javascript -just different.

I guess the point I'm trying to make is that if I inherited a PHP project I wouldn't bother to force it to be node based unless necessary. Otherwise I'd probably start a new project with node (or python depending on the situation).

Collapse
 
th3n00bc0d3r profile image
Muhammad

Agreed, this is a debate that needs a common answer because as 2 or more devs get together that first think comping out is PHP vs Node.