Execute PHP scripts within Node.js web server
Node.js only supports JavaScript. Here is a tutorial on how to have PHP running with Node.js on the side.
http://blog.mixu.net/2011/01/04/nginx-php-fpm-and-node-js-install-on-centos-5-5/
PHP execute nodejs from another server
Many ways to deal with it. Most easiest and straightforward way would be to setup a server on your (or the target) computer and then simply pass on the request. This will be able to control node script and php script individually.
On your PHP file you can simply use file_get_contents
,
$text="some data to pass";
$homepage = file_get_contents("http://YOURPUBLICIPADDRESS:3000/?text=$text");
echo $homepage;
And on your node api, you can have some route which will handle the jsFunction from there, assuming it's a promise, I can probably use expressJS to handle it.
var express = require('express')
var jsFunction = require('./jsFunction')
var app = express()
app.get('/', function (req, res) {
jsFunction(req.query.text).then(data=>res.send({data}))
})
app.listen(3000)
Related Topics
Laravel View Not Found Exception
Why Is PHP Session_Destroy() Not Working
Change Product Prices Via a Hook in Woocommerce 3+
Why Is Json_Encode Adding Backslashes
How to Get the User'S Local Time Instead of the Server'S Time
Replace a Whole Line Where a Particular Word Is Found in a Text File
Header Only Retrieval in PHP Via Curl
Check If a User/Guest Has Purchased Specific Products in Woocommerce
Formatting Datetime Object, Respecting Locale::Getdefault()
How to Properly Escape HTML Form Input Default Values in PHP
Woocommerce: Which Hook to Replace Deprecated "Woocommerce_Add_Order_Item_Meta"
The MySQLi Extension Is Missing. Please Check Your PHP Configuration
How to Access a Property With an Invalid Name
Best Way to Do Multiple Constructors in PHP
How to Make a Simple Crawler in PHP