PHPServerUtils
in package
A utility class controlling the build-in HTTP server in PHP.
Tags
Table of Contents
Methods
- start() : int
- Starts a new HTTP server at the hostname and port provided, and returns the process ID (PID) of the service if it was started successfully.
- status() : bool
- Checks to see if there is a server running locally under the process ID (PID) provided.
- stop() : void
- Stops the server running locally under the process ID (PID) provided.
Methods
start()
Starts a new HTTP server at the hostname and port provided, and returns the process ID (PID) of the service if it was started successfully.
public
static start(string $host, int $port, string $docRoot) : int
Parameters
- $host : string
-
The hostname or IP address
- $port : int
-
The port number to use
- $docRoot : string
-
The file path to directory containing the documents we want to serve
Tags
Return values
intstatus()
Checks to see if there is a server running locally under the process ID (PID) provided.
public
static status(int $PID) : bool
Parameters
- $PID : int
-
The PID of the running server we want to check
Return values
boolstop()
Stops the server running locally under the process ID (PID) provided.
public
static stop(int $PID) : void
Parameters
- $PID : int
-
The PID of the running server we want to stop