4

I'm a PHP Developer by profession and I've never used Node.js in my life.

But I know that Node.js is a cross-platform JavaScript runtime environment that allows developers to build server-side and network applications with JavaScript.

The above statement created one query in my mind that like Node.js is there any runtime environment exist for the server-side programming language PHP?

I've never heard that PHP also has a runtime environment which I always hear in case of Javascript which has Node.js as a runtime environment to build server-side web applications.

Someone please clear my doubt in case of runtime environment for PHP. If it's present where it is and what it comprises of? If not, then explain how does PHP allow to build server-side applications without having a runtime environment?

Following is my current setup for PHP :

I'm using PHP 7.4.2 on my laptop that runs on Windows 10 Home Single Language 64-bit operating system.

I've installed the latest version of XAMPP installer on my laptop which has installed the Apache/2.4.41 (Win64) and PHP 7.4.2

PHPLover
  • 1
  • 51
  • 158
  • 311
  • 1
    Maybe you need first to read [what is Node.js](https://stackoverflow.com/questions/1884724/what-is-node-js) ..? – Teemu Feb 12 '20 at 13:19

1 Answers1

3

I'm not sure to understand yours questions, but i'll try to answer you properly. As en interpreted language I think PHP could not be considered to have runtime environment.

I'll assume by runtime environment you may reference to a complete environment isolated from the other part of the system( like Java VM)

You can use generally PHP in two main ways: - with a web server (websites, web apps..) - a standalone executable (CLI scripts)

  1. With a web server, you can not assume this a runtime environment as it come separately: webserver + php module for this webserver

  2. As a standalone executable, you may have environment variables and others configurable environment elements related but this not isolated from the rest of the operating system:

    • It doesn't execute is own bytecode (however you could use OPCache
    • It doesn't manage it own threads : same as above you can use extension

    It's complety différent from NodeJS which use a VM(V8) from my point of view.

  • **Javascript** is also an **interpreted language** and it has a **runtime environment** present in form of **Node.js**. So your assumption, *"As en interpreted language I think PHP could not be considered to have runtime environment"* which means that **interpreted programming languages** can not have a **runtime environment** is false. I think whether the programming langue is interpreted or complied has nothing to do in having a **runtime environment** for that particular programming language. – PHPLover Feb 12 '20 at 14:03