All Projects → sindresorhus → Php Server

sindresorhus / Php Server

Licence: mit
Start a PHP server

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Php Server

Gulp Server Io
Standalone / gulp (stream) / delivery server setup with Proxy options remote debugger and more
Stars: ✭ 152 (+27.73%)
Mutual labels:  development, webserver
Grunt Php
Start a PHP server
Stars: ✭ 291 (+144.54%)
Mutual labels:  npm-package, webserver
httplab
The interactive web server
Stars: ✭ 3,856 (+3140.34%)
Mutual labels:  development, webserver
Httplab
The interactive web server
Stars: ✭ 3,752 (+3052.94%)
Mutual labels:  development, webserver
wnmp-dev
Development environment: Windows + nginx + MySQL + PHP
Stars: ✭ 52 (-56.3%)
Mutual labels:  development, webserver
Pric
Simple zero-config tool to create Private Certificate Authority & issue locally-trusted development server certificates with any domain names you'd like. SSL certificates for development purposes.
Stars: ✭ 87 (-26.89%)
Mutual labels:  development, webserver
Data Frisk Reagent
Stars: ✭ 110 (-7.56%)
Mutual labels:  development
Hq
Lightning fast, zero configuration, web application development server
Stars: ✭ 114 (-4.2%)
Mutual labels:  development
Chalk Animation
🎬 Colorful animations in terminal output
Stars: ✭ 1,489 (+1151.26%)
Mutual labels:  npm-package
P State
Inspect the state of a promise
Stars: ✭ 108 (-9.24%)
Mutual labels:  npm-package
Doge Seed Cli
Generate dank mnemonic seed phrases in the terminal
Stars: ✭ 118 (-0.84%)
Mutual labels:  npm-package
Get Programming With Nodejs
Code samples for Get Programming with Node.js (See verhagen's VM setup for exercises in this book: https://github.com/verhagen/get-programming-with-nodejs)
Stars: ✭ 117 (-1.68%)
Mutual labels:  development
Node Rus Diff
JSON diff
Stars: ✭ 112 (-5.88%)
Mutual labels:  npm-package
P Queue
Promise queue with concurrency control
Stars: ✭ 1,863 (+1465.55%)
Mutual labels:  npm-package
Wordup Cli
Wordup is a fully integrated development platform for WordPress. Develop plugins and themes locally. Preview in the cloud. Automatic updates in WP.
Stars: ✭ 116 (-2.52%)
Mutual labels:  npm-package
Cra Build Watch
A script for create-react-app that writes development builds to the disk
Stars: ✭ 110 (-7.56%)
Mutual labels:  development
Teenyicons
Tiny minimal 1px icons designed to fit in the smallest places.
Stars: ✭ 1,631 (+1270.59%)
Mutual labels:  npm-package
Playground
Playground
Stars: ✭ 108 (-9.24%)
Mutual labels:  development
Ansible Role Haproxy
Ansible Role - HAProxy
Stars: ✭ 112 (-5.88%)
Mutual labels:  webserver
Xterm.js
A terminal for the web
Stars: ✭ 12,019 (+10000%)
Mutual labels:  development

php-server

Start a PHP server

Uses PHP's built-in development web server (not for production use).

The Node.js process is automatically kept alive as long as the PHP server is running.

Install

$ npm install php-server

Usage

const phpServer = require('php-server');

(async () => {
	const server = await phpServer();
	console.log(`PHP server running at ${server.url}`)
})();

API

phpServer([options])

Returns an object with the following properties:

options

Type: object

port

Type: number
Default: 0

The port on which you want to access the server.

Specify 0 to use a random port.

hostname

Type: string
Default: '127.0.0.1' (Usually the same as localhost)

The hostname the server will use.

Use '0.0.0.0' if you want it to be accessible from the outside.

base

Type: string
Default: '.'

The directory the server will serve from.

open

Type: boolean | string
Default: false

Open the server URL in the browser.

Can be one of the following:

  • true: Opens the default server URL (http://${hostname}${port}).
  • A relative URL: Opens that URL in the browser. Useful when testing pages that are not the default.
env

Type: object
Default: {}

Set environment variables for the PHP process.

router

Type: string

Optionally specify the path to a router script that is run at the start of each HTTP request. If this script returns false, the requested resource is returned as-is. Otherwise, the script's output is returned to the browser.

Example router script:

<?php
// router.php
if (preg_match('/\.(?:png|jpg|jpeg|gif)$/', $_SERVER["REQUEST_URI"])) {
	return false; // Serve the requested resource as-is
} else {
	echo "<p>Thanks for using php-server :)</p>";
}
?>
binary

Type: string
Default: 'php' (The one in your $PATH)

Path to the PHP binary.

Can be useful if you have multiple versions of PHP installed.

ini

Type: string
Default: The built-in php.ini

Path to a custom php.ini config file.

directives

Type: object
Default: {}

Add custom INI directives.

Related

  • grunt-php - Grunt plugin that uses this package

License

MIT © Sindre Sorhus

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].