DEV Community


Discussion on: PHP vs Node.js

kmistele profile image
Kyle Mistele

Great article! Couple thoughts on this -
The “hello world” comparison isn’t quite fair, since for PHP you’re assuming you have a static file server like Apache installed and configured to actually serve the PHP file. The node code creates a server and serves the response, so the two aren’t quite analogous. PHP can also create a lot of security problems if it’s not used right - things like file includes and SQL query generation can go really wrong really easily if not done right.

I’m probably a bit biased though - I’m definitely more of a Node.js fan.

back2lobby profile image

No, he is not assuming any kind of complex apache configuration for that hello world code. PHP has its own built-in server. Its just a simple command "php -S localhost:8000" and thats it. Simple!

tanmaymishu profile image
Tanmay Das

Which is simpler than that of NodeJS ;-)

const http = require('http');

const requestListener = ...

const server = http.createServer(requestListener);

ajayyadav profile image
Ajay Yadav

Php requires apache to run, and node also requires nodejs pre-installed....

I can see your jealousy level 😜

jcarlosweb profile image
Carlos Campos

php -S localhost:8000 -t out/

noclat profile image
Nicolas Torres

PHP does not require Apache to run. You can execute scripts in command line the same way than Node.js.

Thread Thread
kmistele profile image
Kyle Mistele

True, you can definitely install just an executable