Skip to content

Commit 35f4cc5

Browse files
author
Ganesh K Bhat
committed
[COMMIT] [feature] Minor changes to support ES Modules. Adding minor changes to readme
1 parent 2ebac8b commit 35f4cc5

File tree

1 file changed

+57
-66
lines changed

1 file changed

+57
-66
lines changed

README.md

Lines changed: 57 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,135 @@
1-
21
# phpcgijs
32

43
#### Run php scripts like wordpress, drupal, etc with node and cgi counter parts
5-
----------------------------------------------------------------------------
64

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+
---
86

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.
98

10-
Installation
11-
------------
9+
## Installation
1210

1311
```
1412
npm install phpcgijs --save
1513
```
1614

17-
18-
Includes CGIJS Library as a dependancy
19-
---------------------------------------
20-
15+
## Includes CGIJS Library as a dependancy
2116

2217
# cgijs
23-
API for cgijs: `require("phpcgijs").cgijs`
2418

19+
API for cgijs: `require("phpcgijs").cgijs`
2520

2621
#### Usage as `require("phpcgijs").cgijs` inbuilt dependency library APIs
27-
-------------------------------------------------------------------------
2822

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+
---
3024

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._
3126

3227
`CGIJS` library:
3328

3429
- Supports running any `CGI` / `Interpreted Language scripts` in `any OS` that runs `node.js`.
3530
- 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
3832

3933
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)
4034

41-
4235
# phpcgijs
43-
API for cgi: `require("phpcgijs").cgi`
4436

37+
API for cgi: `require("phpcgijs").cgi`
4538

4639
#### Usage as `require("phpcgijs").cgi` inbuilt dependency library APIs
47-
-------------------------------------------------------------------------
4840

49-
To run php scripts with node js and express create the following script like below:
41+
---
5042

51-
```javascript
43+
To run php scripts with node js and express create the following script like below:
5244

53-
var express = require('express');
45+
```javascript
46+
var express = require("express");
5447
var php = require("./main");
55-
// var php = require("phpcgijs");
48+
// var php = require("phpcgijs");
5649
var path = require("path");
5750

5851
var app = express();
5952
var p = path.join("test/php");
6053

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
6257

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+
//
6368
// 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"} }
6871
// ));
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
7174
// 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
7679
// PHP-CGI that you want to use for the application
77-
80+
//
7881
// app.use("/", php.cgi(
79-
// "/path/to/phpscript.php",
82+
// "/path/to/phpscript.php",
8083
// {
8184
// "cgi_path":"to/php/cgi/path/php-cgi",
8285
// "options": {"-c": "/to/php/ini/path/php.ini"}
8386
// }
8487
// ));
88+
//
8589

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");
9291
console.log("Server listening at 9090!");
93-
9492
```
9593

94+
## Explanation
9695

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.
10197

10298
You can also use the inbuilt `cgijs` API using the following features using the `require("phpcgijs").cgijs` API.
10399

104-
105-
Dependencies
106-
------------
107-
100+
## Dependencies
108101

109102
#### Inbuilt phpcgijs `.cgi` usage
110-
-----------------------------------
111103

104+
---
112105

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.
120109

121110
#### Inbuilt phpcgijs `.cgijs` usage
122-
-------------------------------------
123111

112+
---
124113

125114
##### 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
127117

128118
##### 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
130121

131122
##### 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
133125

134126
##### 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
138127

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
139131

140-
License
141-
-------
132+
## License
142133

143134
Copyright © 2019 - till it works Ganesh B for DesktopCGI <[email protected]>
144135

0 commit comments

Comments
 (0)