• This repository has been archived on 15/Jul/2022
  • Stars
    star
    107
  • Rank 323,587 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 11 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Run PHP scripts in node

NodeCGIEmbedded - run php scripts like wordpress, drupal, etc with node and cgi counter parts

With Node PHP Embedded you can leverage the speed of node js and run all of the widely available php scripts directly inside your express site.

This is 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.

Installation

npm install phpcgijs --save

Usage

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");

// Following is the structure for providing the declaration of paths and options:

// 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"}
//             }
//         ));

// 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" } }));
app.listen(9090, '127.0.0.1');
console.log("Server listening at 9090!");

Explanation

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.

Dependencies

php-cgi

  • You need to have the interpreter installed in the system in order to use this extension.
  • Alternatively, You can specify the full path of locally available php-cgi path.
  • If custom path not specified in express, it tries to find the system installed php-cgi executable. If still unavailable, the server errors out.
  • TODO:
    • Add php.ini path config
    • app.use("/", php.cgi("/path/to/phpscript", "to/php/cgi/path", '/path/to/php.ini'));

License

Copyright © 2019 - till it works Ganesh B [email protected]

The MIT License (MIT) - See LICENSE for further details.

More Repositories

1

juci

JUCI JavaScript Webgui for embedded devices running OpenWRT
JavaScript
388
star
2

avr-vt100

AVR ATMega Terminal Emulator
C
83
star
3

martink

Microcontroller Firmware/Driver Library Project for Bare Metal Applications on AVR/ARM SoC devices
C
57
star
4

hack-ssd1306-openwrt

Tutorial on how to connect an ssd1306 oled display to OpenWRT over a usb to i2c dongle (ch341)
C
34
star
5

juci-openwrt-feed

OpenWRT feed with all JUCI related packages.
Makefile
31
star
6

avr-ultimate-driver-pack

** look at martink repository ** .. this one is old.
C
29
star
7

orangerpcd

Websocket RPC server for OpenWRT
Shell
27
star
8

juciwrt

JUCI WebGUI on OpenWRT
C
14
star
9

libfirmware

A firmware library for building applications for various microcontrollers
C
11
star
10

libdriver

A new version of libk where I take a different approach and make it more useful.
C
10
star
11

usynth

AVR ATMega audio synth.
C
9
star
12

ubus-json-server

Json based frontend server for openwrt ubus
C
7
star
13

libasync

An experimental asynchronous task library for C
C
6
star
14

kicad-standard-footprints

KiCad IPC footprint generator that generates footprints from IPC names and CSV files
Python
6
star
15

libblobpack

A library for packing arbitrary data into binary cross platform blobs
Shell
6
star
16

ninjaflight

Fast, clean and well tested.
C
5
star
17

ubus-scriptd

Enabled easy ubus object management through /etc/ubus/
C
5
star
18

autotools-template

Autotools template with coverage
M4
4
star
19

libubus2

New and improved version of libubus for OpenWRT
C
4
star
20

libcanopen

CANOpen implementation for use with TheBoss
C
3
star
21

libnmea

Embedded nmea library
C
3
star
22

bettercopter

** new ** My multirotor helicopter project
C++
3
star
23

openwrt-ubus

Fixed up branch of git://nbd.name/luci2/ubus.git
C
3
star
24

uwrt-utils

Awk
3
star
25

libulink

Shell
2
star
26

openwrt-rpcd

Fixup brunch of git://nbd.name/luci2/rpcd.git
C
2
star
27

mks-openwrt-kernel-feed

My kernel driver packages for openwrt
C
2
star
28

libutype

micro types library for use with ubus2
Shell
2
star
29

kicad-swe-library

2
star
30

openwrt-feed

Misc openwrt packages.
Makefile
1
star
31

libusys

usys: micro system library (for use with ubus2)
Shell
1
star
32

mkschreder.github.io

mkschreder.github.io
HTML
1
star
33

avr-glm

An attempt to port the GLM 3D math library to 8 bit AVR microcontrollers.
C++
1
star
34

libmodbus

C
1
star
35

juci-libubox

C
1
star
36

juci-lighttpd

lighttpd with websocket support integrated into the server (required for juci)
C
1
star
37

juci-uhttpd

C
1
star
38

kicad

My KiCad changes
C
1
star
39

libstm32

C
1
star
40

libfdt

A fork of libfdt with minor modifications to make sure it compiles with warning levels that I require
Shell
1
star