class DevCommands

Constants

protected DEFAULT_MODE

Properties

static protected NodePackageManager|null $packageManager

The resolved NodePackageManager instance.

static protected int $colorCount

Counter to keep track of how many colors have been assigned.

static protected DevCommand> $commands

The registered development commands.

static protected list<string> $only

The names of commands that should be included when running the "dev" command.

static protected list<string> $except

The names of commands that should be excluded when running the "dev" command.

static protected DevCommandMode $mode

The mode in which the "dev" command should run.

static protected bool $withTimestamps

Whether to include timestamps in the output of the "dev" command.

static protected bool $autoRestart

Whether to automatically restart a "dev" command when it fails.

static protected bool $withoutVendorCommands

Whether to exclude vendor commands.

static protected bool $withoutDefaultCommands

Whether to exclude the framework's default commands.

static protected int|null $bufferSize

How many lines of output to buffer for each command when running in tabbed mode.

static protected int|null $streamBufferSize

How many lines of output to buffer total when running in stream mode.

Methods

static void
registerDefaults()

Register the default development commands.

static DevCommand
register(string $command, string|null $name = null)

Register a development command.

static DevCommand
artisan(string $command, string|null $name = null)

Register an Artisan command, automatically prefixing it with "php artisan".

static DevCommand
node(string $command, string|null $name = null)

Register a Node command, automatically prefixing it with the detected package manager's run command.

static DevCommand
nodeExec(string $command, string|null $name = null)

Register a Node command, automatically prefixing it with the detected package manager's exec command.

static array
commands()

Get the registered development commands.

static void
inline()

Set the mode to inline, where all commands are run in the same terminal window.

static void
stream()

Set the mode to stream, where all commands are run in the same terminal window, but their output is interactive within a TUI.

static void
tabs()

Set the mode to tabs, where each command is run in its own terminal tab.

static DevCommandMode
mode()

Get the mode in which the "dev" command should run.

static void
withTimestamps()

Enable timestamps in the output of the "dev" command.

static bool
shouldIncludeTimestamps()

Determine if timestamps should be included in the output of the "dev" command.

static void
disableAutoRestart()

Disable automatic restart of a "dev" command when it fails.

static bool
shouldAutoRestart()

Determine if a "dev" command should automatically restart when it fails.

static void
bufferSize(int $lines)

Set the number of lines of output to buffer for each command when running in tabbed mode.

static int|null
getBufferSize()

Get the number of lines of output to buffer for each command when running in tabbed mode.

static void
streamBufferSize(int $lines)

Set the number of lines of output to buffer total when running in stream mode.

static int|null
getStreamBufferSize()

Get the number of lines of output to buffer total when running in stream mode.

static array
fillInEmptyColors(array $commands)

Fill in any empty colors in the given commands array, ensuring each command has a color assigned.

static string
getColor(array $commands)

Get a color for a command, ensuring that colors are reused only after all available colors have been used at least once.

static array
resolveSource(array $trace)

Resolve the first external caller frame from a debug backtrace.

static int
resolvePriority(array $trace)

Determine the registration priority from a debug backtrace.

static bool
isDependencyFile(string $file)

Determine whether a file belongs to an installed Composer dependency.

static bool
isWithinPath(string $path, string $directory)

Determine whether a path is the given directory or one of its descendants.

static void
only(string ...$names)

Set the commands that should be included when running the "dev" command.

static void
except(string ...$names)

Set the commands that should be excluded when running the "dev" command.

static void
withoutVendorCommands()

Exclude any commands from the vendor directory.

static void
withoutDefaultCommands()

Exclude the framework's default commands.

getPackageManager()

Resolve and return the NodePackageManager instance.

static void
flushState()

Flush all static state.

Details

at line 94
static void registerDefaults()

Register the default development commands.

Boot-only. The commands persist in static properties for the worker lifetime and affect every subsequent development command invocation.

Return Value

void

at line 115
static DevCommand register(string $command, string|null $name = null)

Register a development command.

Boot-only. The command persists in a static property for the worker lifetime and affects every subsequent development command invocation.

Parameters

string $command
string|null $name

Return Value

DevCommand

at line 142
static DevCommand artisan(string $command, string|null $name = null)

Register an Artisan command, automatically prefixing it with "php artisan".

Boot-only. The command persists in a static property for the worker lifetime and affects every subsequent development command invocation.

Parameters

string $command
string|null $name

Return Value

DevCommand

at line 153
static DevCommand node(string $command, string|null $name = null)

Register a Node command, automatically prefixing it with the detected package manager's run command.

Boot-only. The command persists in a static property for the worker lifetime and affects every subsequent development command invocation.

Parameters

string $command
string|null $name

Return Value

DevCommand

at line 164
static DevCommand nodeExec(string $command, string|null $name = null)

Register a Node command, automatically prefixing it with the detected package manager's exec command.

Boot-only. The command persists in a static property for the worker lifetime and affects every subsequent development command invocation.

Parameters

string $command
string|null $name

Return Value

DevCommand

at line 174
static array commands()

Get the registered development commands.

Return Value

array

at line 204
static void inline()

Set the mode to inline, where all commands are run in the same terminal window.

Boot-only. The mode is shared by all development command invocations in the worker.

Return Value

void

at line 214
static void stream()

Set the mode to stream, where all commands are run in the same terminal window, but their output is interactive within a TUI.

Boot-only. The mode is shared by all development command invocations in the worker.

Return Value

void

at line 224
static void tabs()

Set the mode to tabs, where each command is run in its own terminal tab.

Boot-only. The mode is shared by all development command invocations in the worker.

Return Value

void

at line 232
static DevCommandMode mode()

Get the mode in which the "dev" command should run.

Return Value

DevCommandMode

at line 242
static void withTimestamps()

Enable timestamps in the output of the "dev" command.

Boot-only. The setting is shared by all development command invocations in the worker.

Return Value

void

at line 250
static bool shouldIncludeTimestamps()

Determine if timestamps should be included in the output of the "dev" command.

Return Value

bool

at line 260
static void disableAutoRestart()

Disable automatic restart of a "dev" command when it fails.

Boot-only. The setting is shared by all development command invocations in the worker.

Return Value

void

at line 268
static bool shouldAutoRestart()

Determine if a "dev" command should automatically restart when it fails.

Return Value

bool

at line 278
static void bufferSize(int $lines)

Set the number of lines of output to buffer for each command when running in tabbed mode.

Boot-only. The buffer size is shared by all development command invocations in the worker.

Parameters

int $lines

Return Value

void

at line 286
static int|null getBufferSize()

Get the number of lines of output to buffer for each command when running in tabbed mode.

Return Value

int|null

at line 296
static void streamBufferSize(int $lines)

Set the number of lines of output to buffer total when running in stream mode.

Boot-only. The buffer size is shared by all development command invocations in the worker.

Parameters

int $lines

Return Value

void

at line 304
static int|null getStreamBufferSize()

Get the number of lines of output to buffer total when running in stream mode.

Return Value

int|null

at line 315
static protected array fillInEmptyColors(array $commands)

Fill in any empty colors in the given commands array, ensuring each command has a color assigned.

Parameters

array $commands

Return Value

array

at line 331
static protected string getColor(array $commands)

Get a color for a command, ensuring that colors are reused only after all available colors have been used at least once.

Parameters

array $commands

Return Value

string

at line 347
static protected array resolveSource(array $trace)

Resolve the first external caller frame from a debug backtrace.

Parameters

array $trace

Return Value

array

at line 370
static protected int resolvePriority(array $trace)

Determine the registration priority from a debug backtrace.

Parameters

array $trace

Return Value

int

at line 411
static protected bool isDependencyFile(string $file)

Determine whether a file belongs to an installed Composer dependency.

Parameters

string $file

Return Value

bool

at line 437
static protected bool isWithinPath(string $path, string $directory)

Determine whether a path is the given directory or one of its descendants.

Parameters

string $path
string $directory

Return Value

bool

at line 448
static void only(string ...$names)

Set the commands that should be included when running the "dev" command.

Boot-only. The filter persists in a static property for the worker lifetime and affects every subsequent development command invocation.

Parameters

string ...$names

Return Value

void

at line 459
static void except(string ...$names)

Set the commands that should be excluded when running the "dev" command.

Boot-only. The filter persists in a static property for the worker lifetime and affects every subsequent development command invocation.

Parameters

string ...$names

Return Value

void

at line 469
static void withoutVendorCommands()

Exclude any commands from the vendor directory.

Boot-only. The filter is shared by all development command invocations in the worker.

Return Value

void

at line 479
static void withoutDefaultCommands()

Exclude the framework's default commands.

Boot-only. The filter is shared by all development command invocations in the worker.

Return Value

void

at line 487
static protected NodePackageManager getPackageManager()

Resolve and return the NodePackageManager instance.

Return Value

NodePackageManager

at line 495
static void flushState()

Flush all static state.

Return Value

void