| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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 node.js web application or site.
npm install phpcgijs --save
API for cgijs: require("phpcgijs").cgijs
CGIJS is a all featured library to run any CGI mode / Interpreted language script files, or connect to any web application server proxies, or manage processes in the system.
CGIJS library:
You can view more about cgijs at github.com/cgi-js or install it directly at npm cgijs
API for cgi: require("phpcgijs").cgi
To run php scripts with node js and express create the following script like below:
var express = require("express");
var php = require("./main");
// var php = require("phpcgijs");
var path = require("path");
var app = express();
var p = path.join("test/php");
// options are PHP-CGI command line options and can be found in documentation
// It can also be found in readme-php-options.txt (check for update in docs)
// options ignore -h and --help
app.use("/", php.cgi(p, { cgi_path: "/usr/bin/", options: { "-c": "/etc/php.ini" } }));
//
// Following is the STRUCTURE for providing the declaration of paths and options:
//
// app.use("/expresspath", php.cgi("/path/to/phpscript.php", { "cgi_path":"to/php/cgi/path/php-cgi", options: { "-c": "/etc/php.ini" } }))
//
// app.use("/", php.cgi(
// "/path/to/phpscript.php",
// { "options": {"-c": "/to/php/ini/path/php.ini"} }
// ));
//
// Following works without a local PHP-CGI path and tries to
// use PHP-CGI installed in system by default:
//
// app.use("/", php.cgi("/path/to/phpscript"));
//
// Following uses a path in second argument defining the local copy of
// PHP-CGI that you want to use for the application
//
// app.use("/", php.cgi(
// "/path/to/phpscript.php",
// {
// "cgi_path":"to/php/cgi/path/php-cgi",
// "options": {"-c": "/to/php/ini/path/php.ini"}
// }
// ));
//
app.listen(9090, "127.0.0.1");
console.log("Server listening at 9090!");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.
You can also use the inbuilt cgijs API using the following features using the require("phpcgijs").cgijs API.
PHPCGIJS was originally a fork of http://github.com/mkschreder/node-php. PHPCGIJS was later modified for making this library take dynamic PHP pathing, so that it can run without a PHP (or other interpreted language) distribution installed on a machine. PHPCGIJS can work with an embedded PHP binary distribution. PHPCGIJS was later added with CGIJS to make this library comprehensively support most scripting languages long with running any web application behind a proxy using a webserver.
Copyright © 2019 - till it works Ganesh B for DesktopCGI desktopcgi@gmail.com
The MIT License (MIT) - See LICENSE for further details.
| Back | FazBrowse Home | New Git URL |