Documentation

AbstractCommand extends AbstractDispatcher
in package
implements DispatchableInterface, CommandInterface uses ConsoleTrait

AbstractYes

Console abstract command class

Tags
category

Pop

author

Nick Sagona, III nick@popphp.org

copyright

Copyright (c) 2009-2026 Nick Sagona, III

license

https://www.popphp.org/license New BSD License

version
5.0.0

Table of Contents

Interfaces

DispatchableInterface
Dispatchable interface
CommandInterface
Console command interface

Properties

$application  : Application|null
Application object
$console  : Console|null
Console object
$defaultAction  : string
Default action
$help  : string|null
Command help
$name  : string|null
Command name
$params  : string|null
Command params
$scriptName  : string|null
Script name the command was registered under (e.g. './app'), used to recover the command's bare, unprefixed name for subcommand matching

Methods

__construct()  : mixed
Instantiate the command object
__toString()  : string
Return the command name as string
application()  : Application|null
Get application object (alias)
console()  : Console
Get console object (alias)
dispatch()  : void
Dispatch the command
getApplication()  : Application|null
Get application object
getConsole()  : Console|null
Get console object
getDefaultAction()  : string
Get the default action
getHelp()  : string|null
Get the command help
getName()  : string|null
Get the command name
getParams()  : string|null
Get the command params
getScriptName()  : string|null
Get the script name the command was registered under
hasApplication()  : bool
Has application object
hasConsole()  : bool
Has console object
hasHelp()  : bool
Determine if the command has help
hasName()  : bool
Determine if the command has name
hasParams()  : bool
Determine if the command has params
hasScriptName()  : bool
Determine if the command has a script name
setApplication()  : static
Set application object
setConsole()  : static
Set console object
setDefaultAction()  : static
Set the default action
setHelp()  : static
Set the command help
setName()  : static
Set the command name
setParams()  : static
Set the command params
setScriptName()  : static
Set the script name the command was registered under

Properties

$scriptName

Script name the command was registered under (e.g. './app'), used to recover the command's bare, unprefixed name for subcommand matching

protected string|null $scriptName = null

Methods

__construct()

Instantiate the command object

public __construct([Application|null $application = null ][, Console $console = new Console(120) ][, string|null $name = null ][, string|null $params = null ][, string|null $help = null ]) : mixed
Parameters
$application : Application|null = null
$console : Console = new Console(120)
$name : string|null = null
$params : string|null = null
$help : string|null = null

__toString()

Return the command name as string

public __toString() : string
Return values
string

dispatch()

Dispatch the command

public dispatch([string|null $action = null ][, array<string|int, mixed>|null $params = null ]) : void

Resolves to the 'handle' action when none is given, always passing it through as an explicit action name rather than relying on AbstractDispatcher's own default-action fallback, which does not forward $params.

Parameters
$action : string|null = null
$params : array<string|int, mixed>|null = null

getDefaultAction()

Get the default action

public getDefaultAction() : string
Return values
string

getHelp()

Get the command help

public getHelp() : string|null
Return values
string|null

getName()

Get the command name

public getName() : string|null
Return values
string|null

getParams()

Get the command params

public getParams() : string|null
Return values
string|null

getScriptName()

Get the script name the command was registered under

public getScriptName() : string|null
Return values
string|null

hasApplication()

Has application object

public hasApplication() : bool
Return values
bool

hasConsole()

Has console object

public hasConsole() : bool
Return values
bool

hasHelp()

Determine if the command has help

public hasHelp() : bool
Return values
bool

hasName()

Determine if the command has name

public hasName() : bool
Return values
bool

hasParams()

Determine if the command has params

public hasParams() : bool
Return values
bool

hasScriptName()

Determine if the command has a script name

public hasScriptName() : bool
Return values
bool

setConsole()

Set console object

public setConsole([Console $console = new Console(120) ]) : static
Parameters
$console : Console = new Console(120)
Return values
static

setDefaultAction()

Set the default action

public setDefaultAction(string $default) : static
Parameters
$default : string
Return values
static

setHelp()

Set the command help

public setHelp(string $help) : static
Parameters
$help : string
Return values
static

setName()

Set the command name

public setName(string $name) : static
Parameters
$name : string
Return values
static

setParams()

Set the command params

public setParams(string $params) : static
Parameters
$params : string
Return values
static

setScriptName()

Set the script name the command was registered under

public setScriptName(string $scriptName) : static
Parameters
$scriptName : string
Return values
static

        
On this page

Search results