Should I Start With PHP Or Node.js? | PHP vs Node.js

php vs node

PHP vs Node.js!

“I am pretty good at frontend web development and wanted to start backend. Should I start with PHP or Node.js? ”

This is a frequently appearing confusion among beginners, who rush into web development and make a stand-out career. To be precise, both PHP and NodeJS are server-sided scripting languages. It is actually a matter of personal choice to start learning. NodeJS is a bit harder to master, unlike PHP.

PHP Or Node.js: PHP

PHP code is often messy as it has very fewer conventions to follow unless you are using some MVC framework. Frameworks get a lot of the boilerplate out of the way (similar to Cake, Zend, Code Igniter, or whatever you might be familiar with in PHP). It is processed by an interpreter normally installed as a module in a web server such as Apache or Nginx.PHP code can be intermingled with HTML but that’s not considered a best practice.

  • Learning PHP is fun and easy and one can get the basics of it if you know a certain amount of programming.
  • Php also comes with many frameworks which can help you get started in developing large-scale applications. Since you worked on frontend development and handled JavaScript quite well, you might find Nodejs interesting and fun too.
  • You will also find it easy and seamless to work on both frontend and backend using JavaScript. JSON parsing is quite easier in JavaScript than in PHP so it is a plus.
  • Overall javascript is a powerful scripting language and in the future, you may also start developing mobile apps using it, so I say go with Nodejs for now. But yes, if time permits just go through the basics of PHP at least.

PHP Or Node.js: Node.js 

Node.js is the right choice for people getting back into web development.Node.js was created by Ryan Dahl as a pet project in 2009. It uses Google’s V8 JavaScript engine, which is part of the Chrome web browser. Node.js is relatively new but has been rapidly gaining popularity in all major production companies like Microsoft, Yahoo, Linked In, and PayPal.

why Node.js is easy to learn:

  • All web developers already know basic JavaScript, and with Node.js development, that’s the only language you’ll need to learn.
  • Node.js is lightweight and transparent. It doesn’t do a bunch of magic under the hood like Rails or Django do – what you see is generally what you get.
  • There are tons of great free resources for learning Node.js

My personal choice among PHP or Node.js

Start here:

(Forked from TJ Holowaychuk) :

  • Hello, World in NodeJS:

There is lots of information about node.js, this is a simple post for beginners to find good, current information on how to get started.

This post assumes that you are already familiar with JavaScript. If you are not, you should go ahead and read: Eloquent JavaScript, a free online book by Marijn Haverbeke.

  • Hello World Tutorial

This tutorial guides you through installing node.js, including the creation of a simple hello world HTTP server.


Installation Steps

Download the Windows installer from the Nodes.js® website.
Run the installer (.msi file). Click the NEXT button a bunch of times and accept the default installation settings and Restart your computer.

The interactive node.js shell

If everything worked, you should be able to invoke the interactive node.js shell like this. The interactive shell (also called REPL) is a great place to test javascript code.

$ node

console.log(‘Hello World’);
Hello World

To end the node terminal just, Ctrl + C.

Your first program

Writing a node.js program is as simple as creating a new file with a ‘.js’ extension. For example, you could create a simple ‘hello_world.js’ file with the following content:

console.log(‘Hello World’);

After you have saved the file, you can execute it from your terminal like so:

$ node hello.js
Hello World

A hello world HTTP server

Now printing hello world to a terminal isn’t all that exciting. Let’s take the next step and write a program that responds to the hello world via HTTP. We’ll call the file ‘hello_http.js’ and put the following code into it:

var HTTP = require(‘HTTP’);

var server = http.createServer(function(req, res) {
res.end(‘Hello Http’);

Now, let’s run this program from the terminal by typing:

$ node hello_http.js

Wrapping Up on PHP vs Node.js

If you have used any server-side programming language you might have noticed, the first thing you should have is a server. In node, we have just created our own server. A node program will always run until it’s certain that no further events are possible. In this case, the open HTTP server is the source of events that will keep things going.

Testing the server is as simple as opening a new browser tab, and navigating to the following URL: http://localhost:8080/. As expected, you should see a response that reads: ‘Hello Http’.

Happy Journey with NodeJS :

Want to explore more about PHP and master it? Go ahead and explore here!

On the other hand, we have amazing courses on Node.js as well! To find more about them click here!

You may also like...

0 0 votes
Article Rating
Notify of
Newest Most Voted
Inline Feedbacks
View all comments

[…] Node JS, and more.  […]

Would love your thoughts, please comment.x