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 :

  1. from node define php file call
  2. pass arguments php code have context (payload, arguments, header...)
  3. 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.

here documentation how pass data stdin in first place.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -