Running locally a PHP program from the browser with Node.js

Node.js is the link that connects the browser to executable files on a local machine.

The diagram below shows how the system works:

We start node with the server script :

node runphp.js

We type the script's locale URL in the browser :

localhost:1000/dirlist.php

Node launches the execution of the script with the runner.exec command.

The script displays a result with the echo command.

The result is send to a new HTML page by Node.

To start the program, you type the program name in the URL bar:

localhost:1000/dirlist.php

And you can also pass variables to the program, in this form:

localhost:1000/dirlist.php?x=test

The JavaScript code is derived from the server code that was already used to create a HTML file server with Node.js. But this time, instead of displaying the content, we use the module child_process to run the program, and it is then the program output that will be displayed.
It works on a local machine, or on a remote host.

In fact we have with this program the basis for a rudimentary local application server: by changing the script name in the URL bar, you throw different tools.
To automate the running you can put each in bookmark, and even possibly use bookmarklets to pass parameters.
This local server can also be started itself by placing the above command in a batch file that will run at session startup.