$defaultName
$defaultName : string
Default command name.
Serve cli command.
The ServeCommand
starts a development server using PHP's built-in web server.
execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output) : int
Executes the current command.
This method starts a development server using the PHP built-in web server. You can specify the host and port for the server using the '--host' and '--port' options.
\Symfony\Component\Console\Input\InputInterface | $input | Holds an instance of InputInterface. |
\Symfony\Component\Console\Output\OutputInterface | $output | Holds an instance of OutputInterface. |
If 'APP_HOST' or 'APP_PORT' environment variables are missing
Return 0 if the server started successfully, or an exit code if there was an issue.
startServer(string $host, string $port, \Symfony\Component\Console\Output\OutputInterface $output) : void
Starts a development server using PHP's built-in web server.
This method initiates a PHP built-in web server process, binds it to the specified host and port,
and directs the server's output and error messages to the provided OutputInterface
. It uses
proc_open
to manage the server process and capture its output in real-time.
The method does the following:
string | $host | Holds the host name or IP address to bind the server to. |
string | $port | Holds the port number to listen on. |
\Symfony\Component\Console\Output\OutputInterface | $output | Holds the Symfony OutputInterface used for writing messages to the console. |
If there is an issue starting or managing the server process.
This method does not return a value.
command(string $host, string $port, string $base) : string[]
Generate the command parameters for starting the PHP built-in web server.
string | $host | Holds the host name or IP address to bind the server to. |
string | $port | Holds the port to use for the server. |
string | $base | Holds the base path of the application. |
Return an array of command parameters for starting the server.
handleSignals(mixed $process) : void
Set up signal handling to gracefully terminate the PHP built-in server process.
This method enables asynchronous signals handling to allow for graceful termination of the PHP built-in server process when needed.
mixed | $process |
startProcess(string $host, string $port, string $base, \Symfony\Component\Console\Output\OutputInterface $output) : void
Start the PHP built-in server process.
This method starts the PHP built-in server process, handling signals and displaying relevant information in the console output.
string | $host | Holds the hostname or IP address to bind the server to. |
string | $port | Holds the port number to listen on. |
string | $base | Holds the base path of the server's document root. |
\Symfony\Component\Console\Output\OutputInterface | $output | Holds the output interface for displaying server information. |