https://github.com/oscarotero/php-server-manager
Manage PHP built-in server in node
https://github.com/oscarotero/php-server-manager
php-server
Last synced: 11 months ago
JSON representation
Manage PHP built-in server in node
- Host: GitHub
- URL: https://github.com/oscarotero/php-server-manager
- Owner: oscarotero
- License: mit
- Created: 2017-11-18T19:44:37.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-02T22:14:52.000Z (over 6 years ago)
- Last Synced: 2025-03-01T00:58:38.283Z (11 months ago)
- Topics: php-server
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/php-server-manager
- Size: 16.6 KB
- Stars: 29
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Server Manager
Package to manage the PHP built-in server from node.
## Install
```
yarn add php-server-manager
```
## Usage
```js
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:
```js
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:
```js
PHPServer.start();
```
## Use with gulp
```js
gulp.task('php-server', () =>
PHPServer.start({
directory: 'public',
script: 'public/index.php'
})
);
```