Node can execute a php – if a php.ini is in the PATH – with this in the node_helper.js :
const runner = require("child_process");
runner.exec("php " + proxy + " " + params, function(err, data, stderr) {
// ("php timetable.php parameter", function(err, data, stderr) {
var content = data; // "Clean your room - now!"
this.workWithTheData(content);
});
timetable.php :
< ? php // remove spaces
$params = explode(",", $argv[1]); // example, you can leave parameters out (see above)
$content = "Clean your room – now!";
echo $content;
?>
Now that we know we can, let’s talk about if we should: I like it, I use it for a proxy to call APIs while ignoring CORS. BUT I don’t think it makes sense in this case! It’s like using a hammer to fix a loose screw.
To show a static website in the iframe, HTML is enough. Do you really need server side scripts?
If you want a csv, use this in the node_helper.js :
const fs = require("fs"); // before module.exports = ...
getTimeTable: function() {
var rawdata = fs.readFileSync('modules/my-module/file.json'); // or txt or csv
var timetable = JSON.parse(rawdata); // in this case
this.sendSocketNotification("Response", timetable);
}
EDIT: I know that for users with basic HTML or even PHP knowledge, the iFrame solution is an easy win. Use runner or fs if you want to import data directly into your own module.