DEV Community

loading...

Discussion on: PHP vs Node.js

Collapse
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.

Collapse
back2lobby profile image
8ack2Lobby

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!

Collapse
tanmaymishu profile image
Tanmay Das

Which is simpler than that of NodeJS ;-)

const http = require('http');

const requestListener = ...

const server = http.createServer(requestListener);
server.listen(8080);

Collapse
ajayyadav profile image
Ajay Yadav

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

I can see your jealousy level 😜

Collapse
jcarlosweb profile image
Carlos Campos

php -S localhost:8000 -t out/

Collapse
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