node.js - Running PHP from nodejs instance -
i run php nodejs https://www.npmjs.com/package/node-php
it nice guess it's working old version of express , repo doesn't maintained anymore.
looked like
var php = require('php'); var app = express(); app.use("/", php.cgi("/path/to/wordpress")); app.listen(3000);
and every request made /
ending .php
call cgi script run php , return result.
now trying achieve, looks more :
- from node define php file call
- pass arguments php code have context (payload, arguments, header...)
- read php code response (preferably in json format)
is there anyway using nodejs or need to web call proposed call php methods nodejs ?
not having start php webserver preferable require more setup , project wouldn't "work out of box", prefer install php5 , it's done (i guess safe memory / proccess these call should use often)
you can pass input through via stdin
, read fopen("php://stdin")
regular file (file_get_contents("php://input")
works too). assumes want run simple php script, not expects aspects of http request.
the output dependent on code, make sure call json_encode()
when returning.
Comments
Post a Comment