Class \Prado\Shell\Actions\TWebServerAction
This class serves the application with the built-in PHP testing web server.
When no network address is specified, the web server will listen on the default 127.0.0.1 network interface and on port 8080. The application is accessible on the machine web browser at web address "http://127.0.0.1:8080/".
The command option --address=localhost
can specify the network address both
with and without a port. A port can also be specified with the network address,
eg --address=localhost:8777
.
if the machine "hosts" file maps a domain name to 127.0.0.1/localhost, then that
domain name can be specified with --address=testdomain.com
and is accessible
on the machine web browser at "http://testdomain.com/". In this example, testdomain.com
maps to 127.0.0.1 in the system's "hosts" file.
The network address can be changed to IPv6 with the command line option --ipv6
.
To serve pages on all network addresses, including any internet IP address, include
the option --all
. These options only work when there is no address specified.
The command line option --port=8777
can be used to change the port; in this example
to port 8777. Ports 1023 and below are typically reserved for application and
system use and cannot be specified without administration access.
To have more than one worker (to handle multiple requests), specify the --workers=8
command option (with the number of page workers need for you). In this example,
eight concurrent workers are created.
The TWebServerAction is only available when the application is in "Debug" mode. In other Application modes, this action can be enabled with the Prado Application Parameter "Prado:PhpWebServer" set to "true". eg. Within the Application configuration:
<parameters>
<parameter id="Prado:PhpWebServer" value="true" />
</parameters>
Class hierarchy
Author: Brad Anderson <belisoful@icloud.com>Since: 4.3.0
public
|
|
public
|
generateCommand(string $address, string $documentRoot, string|null $router) : array<string|int, mixed>
|
public
|
getAddress() : string
Gets the network address to serve pages from. When no network address is specified
then this will return the proper network address based upon {@see self::getIpv6()}
and {@see self::getAll()}.
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
optionAliases() : array<string, string>
Aliases for the properties to be set by parameter. 'i' is for 'interface'.
|
public
|
|
public
|
|
public
|
setAll(mixed $value) : bool
This option is only used when no network interface is specified. When called
without a $value (null or ''), All is set to true.
|
public
|
setIpv6(null|bool|string $ipv6) : static
When called without a $value (null or ''), Ipv6 is set to true.
|
public
|
|
public
|
setWorkers(null|int|string $value) : static
When called without a value (null or '') then the number of workers is set to 8.
|
protected
|
isAddressTaken(string $hostname, int $port) : bool
This checks if a specific hostname and port are currently being used in the system
|
public
mixed
|
DEV_WEBSERVER_ENV
|
'PRADO_DEV_WEBSERVER'
|
public
mixed
|
DEV_WEBSERVER_PARAM
|
'Prado:PhpWebServer'
|
public
mixed
|
WORKERS_ENV
|
'PHP_CLI_SERVER_WORKERS'
|
\Prado\TComponent::GLOBAL_RAISE_EVENT_LISTENER |