@@ -21,25 +21,47 @@ Usage
2121To run php scripts with node js and express create the following script like below:
2222
2323``` javascript
24+
2425var express = require (' express' );
25- var php = require (" phpcgijs" );
26- var path = require (" path" );
26+ var php = require (" ./main" );
27+ // var php = require("phpcgijs");
28+ var path = require (" path" );
2729
2830var app = express ();
31+ var p = path .join (" test/php" );
32+
33+ // Following is the structure for providing the declaration of paths and options:
2934
30- // Following is the structure for providing the decalration of paths
31- // app.use("/", php.cgi("/path/to/phpscript", "to/php/cgi/path/php-cgi.exe"));
35+ // app.use("/", php.cgi(
36+ // "/path/to/phpscript.php",
37+ // {
38+ // "options": {"-c": "/to/php/ini/path/php.ini"}
39+ // }
40+ // ));
41+
42+ // Following works without a local PHP-CGI path and tries to
43+ // use PHP-CGI installed in system by default:
3244
33- // Following works without a local PHP-CGI path and tries to use PHP-CGI installed in system by default
3445// app.use("/", php.cgi("/path/to/phpscript"));
3546
36- // Following uses a path in second argument defining the local copy of PHP-CGI that you want to use for the application
37- app .use (" /" , php .cgi (" /path/to/phpscript" , " to/php/cgi/path/php-cgi" ));
47+ // Following uses a path in second argument defining the local copy of
48+ // PHP-CGI that you want to use for the application
49+
50+ // app.use("/", php.cgi(
51+ // "/path/to/phpscript.php",
52+ // {
53+ // "cgi_path":"to/php/cgi/path/php-cgi",
54+ // "options": {"-c": "/to/php/ini/path/php.ini"}
55+ // }
56+ // ));
3857
58+ // options are PHP-CGI command line options and can be found in documentation
59+ // It can also be found in readme-php-options.txt (check for update in docs)
3960
61+ app .use (" /" , php .cgi (p, { cgi_path: ' /usr/bin/' , options: { " -c" : " /etc/php.ini" } }));
62+ app .listen (9090 , ' 127.0.0.1' );
63+ console .log (" Server listening at 9090!" );
4064
41- app .listen (9090 );
42- console .log (" Server listening!" );
4365```
4466
4567Explanation
0 commit comments