All Projects → oscarotero → php-server-manager

oscarotero / php-server-manager

Licence: MIT license
Manage PHP built-in server in node

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to php-server-manager

mixerapi
A CakePHP Plugin for RESTful API Development [READ-ONLY]
Stars: ✭ 26 (+13.04%)
Mutual labels:  php-server
reactive-slim
A bridge to use SlimPHP within ReactPHP
Stars: ✭ 25 (+8.7%)
Mutual labels:  php-server
rawphp
A powerful, robust and API-first, PHP framework that helps people from different PHP backgrounds work on the same project seamlessly. You can write Laravel, CakePHP, Slim, Symphone and Procedural PHP code inside it and it all works perfectly. Its the PHP Framework for everyone.
Stars: ✭ 31 (+34.78%)
Mutual labels:  php-server
php-server
Fine tuning on the PHP Built-in web server
Stars: ✭ 23 (+0%)
Mutual labels:  php-server
vscode-phpserver
Visual Studio Code extension to quickly serve your PHP projects :)
Stars: ✭ 62 (+169.57%)
Mutual labels:  php-server

PHP Server Manager

Package to manage the PHP built-in server from node.

Install

yarn add php-server-manager

Usage

const PHPServer = require('php-server-manager');

const server = new PHPServer();

server.run(cb); // http://localhost:8000

Callback vs Promise

You can pass a callback to the run method, this will get called when the PHP server is up and running. If you don't pass a callback to the run method, a promise will be returned that resolves when the PHP server is up and running.

Configuration

Name Default Description
php php The php command file
host 127.0.0.1 The server's host
port 8000 The port used
directory null The document root. By default is the current working directory
script null The "router" script
stdio inherit stdio option passed to the spawned process - https://nodejs.org/api/child_process.html#child_process_options_stdio
directives {} An object with the custom PHP directives
config null The path of a custom php.ini file
env process.env The environment variables passed

Example:

const PHPServer = require('php-server-manager');

const server = new PHPServer({
    port: 3000,
    directives: {
        display_errors: 0,
        expose_php: 0
    }
});

server.run();

Quick use

You can use the static function start() to create and run a PHPServer in a single line:

PHPServer.start();

Use with gulp

gulp.task('php-server', () =>
    PHPServer.start({
        directory: 'public',
        script: 'public/index.php'
    })
);
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].