1.1.0 • Published 6 years ago

php-fpm v1.1.0

Weekly downloads
34
License
MIT
Repository
github
Last release
6 years ago

node-php-fpm

NPM Version NPM Downloads

Install

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install php-fpm

Examples

Using with http

const http = require('http')
const phpFpm = require('php-fpm')
const serveStatic = require('serve-static')

const php = phpFpm() // Optional: parameters for fastcgi-client
const serve = serveStatic(__dirname)

const server = http.createServer(function (req, res) {
  if (req.url.match(/\.php(\?.*)?$/)) {
    php(req, res)
  } else {
    serve(req, res)
  }
})

server.listen(8080)

Using with express

const express = require('express')
const phpFpm = require('php-fpm')

const app = express()

app.use(phpFpm())

app.listen(8080)

API

The available parameters for php-fpm are:

phpFpm(
  userOptions = {
    // Parameters for fastcgi-client
    host: '127.0.0.1',
    port: 9000,
    documentRoot: __dirname,
    skipCheckServer: true
  },
  customParams = {
    // Headers for php-fpm (automatically set)
    uri, // REQUEST_URI
    document, // DOCUMENT_URI
    query, // QUERY_STRING
    script // SCRIPT_FILENAME
  }
)

Parameters for fastcgi-client are available here.

rewrite option

There is an implementation of the rewrite module to handle routes the traditional nginx/Apache way.

const phpFpm = require('php-fpm')

// Route rewrite for Phalcon framework
const php = phpFpm({
  rewrite: [
    {
      rule: /.*/, // Default rule, can be omitted
      replace: '/index.php?_url=$0'
    }
  ]
})

License

MIT

1.1.0

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago