node-phpcgi
A simple middleware for node to execute php with php-cgi.
Foreword
Before using this, make sure you have already installed the php-cgi
Note:Not the php command.
Quick Start
First, install it in your project directory:
npm install node-phpcgi
Then, use it in your node server like this:
var middleware = documentRoot: __dirname // change it to your own handler path handler: '/usr/local/php/bin/php-cgi';var app = http;
If you are using connect, you can use it like this:
var connect = ;var phpcgi = documentRoot: __dirname // change it to your own path handler: '/usr/local/php/bin/php-cgi';var app = ;app;
If you are using koa2
, you can use it like this:
const Koa = ;const app = ; const phpcgi = ; app;
Specially for edp, you can use it like this:
location: /\.php/ handler:
Customize
If you want to specify the arguments for php, just add them:
var middleware = ;
Test
Clone into somewhere:
git clone https://github.com/hushicai/node-phpcgi.git
Before you can run the tests, you should change the handler path in the test/spec.js
file:
var middleware = ;
If you does not install the global mocha
, install it:
npm install -g mocha
After that, you can do this:
# cd the repo directory npm installmocha
This package is inspired from gateway.