PHP Class SimpleSAML\Test\BuiltInServer

Show file Open project: simplesamlphp/simplesamlphp Class Usage Examples

Protected Properties

Property Type Description
$address string The address (host:port) where the server is listening for connections after being started.
$docroot string The document root of the server.
$pid integer The PID of the running server.
$router string The name of a "router" file to run for every request performed to this server.

Public Methods

Method Description
__construct ( string | null $router = null, string | null $docroot = null ) BuiltInServer constructor.
get ( string $query, array $parameters, array $curlopts = [] ) : array | string This function performs an HTTP GET request to the built-in server.
getPid ( ) : integer Get the PID of the running server.
getRouter ( ) : string Get the name of the "router" file.
setRouter ( string $router ) Set the "router" file.
start ( ) : string Start the built-in server in a random port.
stop ( ) Stop the built-in server.

Method Details

__construct() public method

BuiltInServer constructor.
See also: http://php.net/manual/en/features.commandline.webserver.php
public __construct ( string | null $router = null, string | null $docroot = null )
$router string | null The name of a "router" file to run first for every request performed to this server.
$docroot string | null The document root to use when starting the server.

get() public method

This function performs an HTTP GET request to the built-in server.
public get ( string $query, array $parameters, array $curlopts = [] ) : array | string
$query string The query to perform.
$parameters array An array (can be empty) with parameters for the requested URI.
$curlopts array An array (can be empty) with options for cURL.
return array | string The response obtained from the built-in server.

getPid() public method

Get the PID of the running server.
public getPid ( ) : integer
return integer The PID of the server, or 0 if the server was not started.

getRouter() public method

Get the name of the "router" file.
public getRouter ( ) : string
return string The name of the "router" file.

setRouter() public method

Set the "router" file.
public setRouter ( string $router )
$router string The name of a "router" file to use when starting the server.

start() public method

This method will wait up to 5 seconds for the server to start. When it returns an address, it is guaranteed that the server has started and is listening for connections. If it returns false on the other hand, there will be no guarantee that the server started properly.
public start ( ) : string
return string The address where the server is listening for connections, or false if the server failed to start for some reason.

stop() public method

Stop the built-in server.
public stop ( )

Property Details

$address protected property

The address (host:port) where the server is listening for connections after being started.
protected string $address
return string

$docroot protected property

The document root of the server.
protected string $docroot
return string

$pid protected property

The PID of the running server.
protected int $pid
return integer

$router protected property

The name of a "router" file to run for every request performed to this server.
protected string $router
return string