API Documentation

ServeCommand extends Command
in package

Start the realtime compiler server.

Tags
see
https://github.com/hydephp/realtime-compiler

Table of Contents

Constants

USER_EXIT  = 130

Properties

$console  : ConsoleOutput
$description  : string
$signature  : string

Methods

askForString()  : string|null
fileLink()  : string
Create a filepath that can be opened in the browser from a terminal.
gray()  : void
Write a grey-coloured line
handle()  : int
The base handle method that can be overridden by child classes.
handleException()  : int
Handle an exception that occurred during command execution.
indentedLine()  : void
Write a line with the specified indentation level
infoComment()  : void
Write a nicely formatted and consistent message to the console. Using InfoComment for a lack of a better term.
safeHandle()  : int
This method can be overridden by child classes to provide automatic exception handling.
checkArgvForOption()  : string|null
Fallback check so that an environment option without a value is acknowledged as true.
configureOutput()  : void
getEnvironmentVariables()  : array<string|int, mixed>
getExecutablePath()  : string
getHostSelection()  : string
getOpenCommand()  : string|null
getOutputHandler()  : Closure
getPortSelection()  : int
openInBrowser()  : void
parseEnvironmentOption()  : string|null
printStartMessage()  : void
runServerProcess()  : void
useBasicOutput()  : bool

Constants

USER_EXIT

public final mixed USER_EXIT = 130

Properties

$description

protected string $description = 'Start the realtime compiler server'

$signature

protected string $signature = 'serve {--host= : <comment>[default: "localhost"]</comment>}} {--port= : <comment>[default: 8080]</comment>} {--save-preview= : Should the served page be saved to disk? (Overrides config setting)} {--dashboard= : Enable the realtime compiler dashboard. (Overrides config setting)} {--pretty-urls= : Enable pretty URLs. (Overrides config setting)} {--play-cdn= : Enable the Tailwind Play CDN. (Overrides config setting)} {--open=false : Open the site preview in the browser.} '

Methods

askForString()

public askForString(string $question[, string|null $default = null ]) : string|null
Parameters
$question : string
$default : string|null = null
Return values
string|null

Create a filepath that can be opened in the browser from a terminal.

public static fileLink(string $path[, string|null $label = null ]) : string
Parameters
$path : string
$label : string|null = null

If provided, the link will be wrapped in a Symfony Console href tag. Note that not all terminals support this, and it may lead to only the label being shown, and the path being lost to the void.

Return values
string

gray()

Write a grey-coloured line

public gray(string $string) : void
Parameters
$string : string

handle()

The base handle method that can be overridden by child classes.

public handle() : int

Alternatively, implement the safeHandle method in your child class to utilize the automatic exception handling provided by this method.

Return values
int

The exit code.

handleException()

Handle an exception that occurred during command execution.

public handleException(Exception $exception) : int
Parameters
$exception : Exception
Return values
int

The exit code

indentedLine()

Write a line with the specified indentation level

public indentedLine(int $spaces, string $string) : void
Parameters
$spaces : int
$string : string

infoComment()

Write a nicely formatted and consistent message to the console. Using InfoComment for a lack of a better term.

public infoComment(string $string) : void

Text in [brackets] will automatically be wrapped in tags.

Parameters
$string : string

safeHandle()

This method can be overridden by child classes to provide automatic exception handling.

public safeHandle() : int

Existing code can be converted simply by renaming the handle() method to safeHandle().

Return values
int

The exit code.

checkArgvForOption()

Fallback check so that an environment option without a value is acknowledged as true.

protected checkArgvForOption(string $name) : string|null
Parameters
$name : string
Return values
string|null

getEnvironmentVariables()

protected getEnvironmentVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>

getExecutablePath()

protected getExecutablePath() : string
Return values
string

getHostSelection()

protected getHostSelection() : string
Return values
string

getOpenCommand()

protected getOpenCommand(string $osFamily) : string|null
Parameters
$osFamily : string
Return values
string|null

getOutputHandler()

protected getOutputHandler() : Closure
Return values
Closure

getPortSelection()

protected getPortSelection() : int
Return values
int

openInBrowser()

protected openInBrowser([string $path = '/' ]) : void
Parameters
$path : string = '/'

parseEnvironmentOption()

protected parseEnvironmentOption(string $name) : string|null
Parameters
$name : string
Return values
string|null

printStartMessage()

protected printStartMessage() : void

runServerProcess()

protected runServerProcess(string $command) : void
Parameters
$command : string

useBasicOutput()

protected useBasicOutput() : bool
Return values
bool

        
On this page

Search results