A node.js tool to launch PHP built-in servers.
- php >= 5.4.0 on your system.
$ npm install php-built-in-server
var PHPServer = require('php-built-in-server');
Simple usage
var server = new PHPServer();
server.on('listening', function (event) {
console.log('[LISTENING]', event.host.address + ':' + event.host.port);
});
server.on('error', function (event) {
console.log('[ERROR]', event.error.toString());
});
server.listen();
Explicit parameters
var server = new PHPServer('path/to/phpExecutable', '/path/to/php.ini');
server.on('listening', function (event) {
console.log('[LISTENING]', event.host.address + ':' + event.host.port);
});
server.on('error', function (event) {
console.log('[ERROR]', event.error.toString());
});
// pathes can be absolute or relatives
server.listen( 'path/to/webRoot', '127.0.0.1', 8000, '/path/to/router.php', {
max_execution_time: 60,
error_log: '/path/to/file', // path here is send to php as is
// etc.
});
Show "examples" folder.
- find solution for partial buffering of stderr:
fwrite(fopen('php://stderr', 'w'), 'test');
is immediatly receive from PHP but stderr datas coming from server himself is buffured.
If someone knows how to fix this...
- No data is received from the child process to confirm explicitly that the server is listening.
- The stderr of the child process logs all queries, not just errors.
- The stderr seems buffered (show TODO).
Copyright (c) 2013 Valéry Herlaud. Licensed under the MIT license. See the file LICENSE.md in this distribution for more details.