|
1 |
| - |
2 | 1 | # phpcgijs
|
3 | 2 |
|
4 | 3 | #### Run php scripts like wordpress, drupal, etc with node and cgi counter parts
|
5 |
| ----------------------------------------------------------------------------- |
6 | 4 |
|
7 |
| -With Node PHP Embedded (PHPCGIJS), you can leverage the speed of node.js and run all of the widely available php scripts directly inside your express site. This was originally a fork of http://github.com/mkschreder/node-php and has been modified for making this take dynamic PHP pathing, so that it can run without a PHP distribution installed on a machine and can work with an embedded PHP binary distribution. |
| 5 | +--- |
8 | 6 |
|
| 7 | +With Node PHP Embedded (PHPCGIJS), you can leverage the speed of node.js and run all of the widely available php scripts directly inside your express site. This was originally a fork of http://github.com/mkschreder/node-php and has been modified for making this take dynamic PHP pathing, so that it can run without a PHP distribution installed on a machine and can work with an embedded PHP binary distribution. |
9 | 8 |
|
10 |
| -Installation |
11 |
| ------------- |
| 9 | +## Installation |
12 | 10 |
|
13 | 11 | ```
|
14 | 12 | npm install phpcgijs --save
|
15 | 13 | ```
|
16 | 14 |
|
17 |
| - |
18 |
| -Includes CGIJS Library as a dependancy |
19 |
| ---------------------------------------- |
20 |
| - |
| 15 | +## Includes CGIJS Library as a dependancy |
21 | 16 |
|
22 | 17 | # cgijs
|
23 |
| -API for cgijs: `require("phpcgijs").cgijs` |
24 | 18 |
|
| 19 | +API for cgijs: `require("phpcgijs").cgijs` |
25 | 20 |
|
26 | 21 | #### Usage as `require("phpcgijs").cgijs` inbuilt dependency library APIs
|
27 |
| -------------------------------------------------------------------------- |
28 | 22 |
|
29 |
| -*`CGIJS` is a library to run any `CGI` mode / `Interpreted language script` files, or connect to any web application server proxies, or manage processes in the system.* |
| 23 | +--- |
30 | 24 |
|
| 25 | +_`CGIJS` is a library to run any `CGI` mode / `Interpreted language script` files, or connect to any web application server proxies, or manage processes in the system._ |
31 | 26 |
|
32 | 27 | `CGIJS` library:
|
33 | 28 |
|
34 | 29 | - Supports running any `CGI` / `Interpreted Language scripts` in `any OS` that runs `node.js`.
|
35 | 30 | - Supports both `CGI` executables as well as `proxy` to `localhost`/ `remote` /`embedded servers` using proxying of multiple protocols (`http`, `websockets`, `tcp`, `udp`, `socks`, `ssh`, `ftp`).
|
36 |
| -- Supports managing processes like `embedded` `server` executables, embedded `database` executables, or `any other` embedded/ non-embedded executables |
37 |
| - |
| 31 | +- Supports managing processes like `embedded` `server` executables, embedded `database` executables, or `any other` embedded/ non-embedded executables |
38 | 32 |
|
39 | 33 | You can view more about `cgijs` at [github.com/cgi-js](https://github.com/cgi-js/cgi-js) or install it directly at [npm cgijs](https://www.npmjs.com/package/cgijs)
|
40 | 34 |
|
41 |
| - |
42 | 35 | # phpcgijs
|
43 |
| -API for cgi: `require("phpcgijs").cgi` |
44 | 36 |
|
| 37 | +API for cgi: `require("phpcgijs").cgi` |
45 | 38 |
|
46 | 39 | #### Usage as `require("phpcgijs").cgi` inbuilt dependency library APIs
|
47 |
| -------------------------------------------------------------------------- |
48 | 40 |
|
49 |
| -To run php scripts with node js and express create the following script like below: |
| 41 | +--- |
50 | 42 |
|
51 |
| -```javascript |
| 43 | +To run php scripts with node js and express create the following script like below: |
52 | 44 |
|
53 |
| -var express = require('express'); |
| 45 | +```javascript |
| 46 | +var express = require("express"); |
54 | 47 | var php = require("./main");
|
55 |
| -// var php = require("phpcgijs"); |
| 48 | +// var php = require("phpcgijs"); |
56 | 49 | var path = require("path");
|
57 | 50 |
|
58 | 51 | var app = express();
|
59 | 52 | var p = path.join("test/php");
|
60 | 53 |
|
61 |
| -// Following is the structure for providing the declaration of paths and options: |
| 54 | +// options are PHP-CGI command line options and can be found in documentation |
| 55 | +// It can also be found in readme-php-options.txt (check for update in docs) |
| 56 | +// options ignore -h and --help |
62 | 57 |
|
| 58 | +app.use( |
| 59 | + "/", |
| 60 | + php.cgi(p, { cgi_path: "/usr/bin/", options: { "-c": "/etc/php.ini" } }) |
| 61 | +); |
| 62 | + |
| 63 | +// |
| 64 | +// Following is the STRUCTURE for providing the declaration of paths and options: |
| 65 | +// |
| 66 | +// app.use("/expresspath", php.cgi("/path/to/phpscript.php", { "cgi_path":"to/php/cgi/path/php-cgi", options: { "-c": "/etc/php.ini" } })) |
| 67 | +// |
63 | 68 | // app.use("/", php.cgi(
|
64 |
| -// "/path/to/phpscript.php", |
65 |
| -// { |
66 |
| -// "options": {"-c": "/to/php/ini/path/php.ini"} |
67 |
| -// } |
| 69 | +// "/path/to/phpscript.php", |
| 70 | +// { "options": {"-c": "/to/php/ini/path/php.ini"} } |
68 | 71 | // ));
|
69 |
| - |
70 |
| -// Following works without a local PHP-CGI path and tries to |
| 72 | +// |
| 73 | +// Following works without a local PHP-CGI path and tries to |
71 | 74 | // use PHP-CGI installed in system by default:
|
72 |
| - |
73 |
| -// app.use("/", php.cgi("/path/to/phpscript")); |
74 |
| - |
75 |
| -// Following uses a path in second argument defining the local copy of |
| 75 | +// |
| 76 | +// app.use("/", php.cgi("/path/to/phpscript")); |
| 77 | +// |
| 78 | +// Following uses a path in second argument defining the local copy of |
76 | 79 | // PHP-CGI that you want to use for the application
|
77 |
| - |
| 80 | +// |
78 | 81 | // app.use("/", php.cgi(
|
79 |
| -// "/path/to/phpscript.php", |
| 82 | +// "/path/to/phpscript.php", |
80 | 83 | // {
|
81 | 84 | // "cgi_path":"to/php/cgi/path/php-cgi",
|
82 | 85 | // "options": {"-c": "/to/php/ini/path/php.ini"}
|
83 | 86 | // }
|
84 | 87 | // ));
|
| 88 | +// |
85 | 89 |
|
86 |
| -// options are PHP-CGI command line options and can be found in documentation |
87 |
| -// It can also be found in readme-php-options.txt (check for update in docs) |
88 |
| -// options ignore -h and --help |
89 |
| - |
90 |
| -app.use("/", php.cgi(p, { cgi_path: '/usr/bin/', options: { "-c": "/etc/php.ini" } })); |
91 |
| -app.listen(9090, '127.0.0.1'); |
| 90 | +app.listen(9090, "127.0.0.1"); |
92 | 91 | console.log("Server listening at 9090!");
|
93 |
| - |
94 | 92 | ```
|
95 | 93 |
|
| 94 | +## Explanation |
96 | 95 |
|
97 |
| -Explanation |
98 |
| ------------ |
99 |
| - |
100 |
| -The script will pipe all files that end in the .php extension through the php parser. All other files will be served as static content. Basic permalinks are supported but the support for them can probably be improved. |
| 96 | +The script will pipe all files that end in the .php extension through the php parser. All other files will be served as static content. Basic permalinks are supported but the support for them can probably be improved. |
101 | 97 |
|
102 | 98 | You can also use the inbuilt `cgijs` API using the following features using the `require("phpcgijs").cgijs` API.
|
103 | 99 |
|
104 |
| - |
105 |
| -Dependencies |
106 |
| ------------- |
107 |
| - |
| 100 | +## Dependencies |
108 | 101 |
|
109 | 102 | #### Inbuilt phpcgijs `.cgi` usage
|
110 |
| ------------------------------------ |
111 | 103 |
|
| 104 | +--- |
112 | 105 |
|
113 |
| -* You need to have the interpreter installed in the system in order to use this extension. |
114 |
| -* Alternatively, You can specify the full path of locally available php-cgi path. |
115 |
| -* If custom path not specified in express, it tries to find the system installed php-cgi executable. If still unavailable, the server errors out. |
116 |
| -* TODO: |
117 |
| - - Add `php.ini` path config |
118 |
| - - `app.use("/", php.cgi("/path/to/phpscript", "to/php/cgi/path", '/path/to/php.ini'));` |
119 |
| - |
| 106 | +- You need to have the interpreter installed in the system in order to use this extension. |
| 107 | +- Alternatively, You can specify the full path of locally available php-cgi path. |
| 108 | +- If custom path not specified in express, it tries to find the system installed php-cgi executable. If still unavailable, the server errors out. |
120 | 109 |
|
121 | 110 | #### Inbuilt phpcgijs `.cgijs` usage
|
122 |
| -------------------------------------- |
123 | 111 |
|
| 112 | +--- |
124 | 113 |
|
125 | 114 | ##### Node CGI Embedded - run interpreted scripts that support cgi using nodejs - `.init` , `.file` API
|
126 |
| -* [x] CGI file execution - Run any scripts that support CGI based serving/execution |
| 115 | + |
| 116 | +- [x] CGI file execution - Run any scripts that support CGI based serving/execution |
127 | 117 |
|
128 | 118 | ##### Node Web Proxy - run web proxies using `.proxy` API
|
129 |
| -* [x] Running Proxies - Run any host that serves a web app, using proxy (HTTP, UDP, TCP, Websockets, Socks) and supports websocket implementation in web proxies |
| 119 | + |
| 120 | +- [x] Running Proxies - Run any host that serves a web app, using proxy (HTTP, UDP, TCP, Websockets, Socks) and supports websocket implementation in web proxies |
130 | 121 |
|
131 | 122 | ##### Node Processes - Manage web servers, database processes, or other system processes or services using `.process` API
|
132 |
| -* [x] Manage Processes or Services - Allows running and closing process Executables |
| 123 | + |
| 124 | +- [x] Manage Processes or Services - Allows running and closing process Executables |
133 | 125 |
|
134 | 126 | ##### CGIJS Functionality Details
|
135 |
| -* [x] The script should support piping all files of below interpreted languages including Python (2.x, 3.x) - `py`, Perl (Version Independent) - `plc`, `pld`, `pl`, PHP (Version Independent) - `php`, Ruby (Version Independent) - `rb`, Node.js (Version Independent) - `js`, CGI files - `cgi`. |
136 |
| -* [x] The script should support piping all proxies of above languages and Jsp (With Tomcat, or any webserver as proxy) , Aspx (With IIS, Apache, or any webserver as proxy), Jsp and Aspx (With Tomcat, Nginx, and Apache embedded) |
137 |
| -* [x] Some sections are pending to be tested but should function normally |
138 | 127 |
|
| 128 | +- [x] The script should support piping all files of below interpreted languages including Python (2.x, 3.x) - `py`, Perl (Version Independent) - `plc`, `pld`, `pl`, PHP (Version Independent) - `php`, Ruby (Version Independent) - `rb`, Node.js (Version Independent) - `js`, CGI files - `cgi`. |
| 129 | +- [x] The script should support piping all proxies of above languages and Jsp (With Tomcat, or any webserver as proxy) , Aspx (With IIS, Apache, or any webserver as proxy), Jsp and Aspx (With Tomcat, Nginx, and Apache embedded) |
| 130 | +- [x] Some sections are pending to be tested but should function normally |
139 | 131 |
|
140 |
| -License |
141 |
| -------- |
| 132 | +## License |
142 | 133 |
|
143 | 134 | Copyright © 2019 - till it works Ganesh B for DesktopCGI <[email protected]>
|
144 | 135 |
|
|
0 commit comments