\Inhere\ConsoleApplication

Class App

Summary

Methods
Properties
Constants
__construct()
controller()
addGroup()
addController()
controllers()
setControllers()
addControllers()
command()
addCommand()
addCommands()
commands()
registerCommands()
registerGroups()
dispatch()
No public properties found
No constants found
getFileFilter()
runCommand()
runAction()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct(array  $config = array(), \Inhere\Console\IO\Input|null  $input = null, \Inhere\Console\IO\Output|null  $output = null) 

Class constructor.

Parameters

array $config
\Inhere\Console\IO\Input|null $input
\Inhere\Console\IO\Output|null $output

controller()

controller(\Inhere\Console\string  $name,   $class = null,   $option = null) 

{@inheritdoc}

Parameters

\Inhere\Console\string $name
$class
$option

addGroup()

addGroup(string  $name, string|\Inhere\Console\Contract\ControllerInterface  $class = null, null|array|string  $option = null) : \Inhere\Console\Application|\Inhere\Console\Contract\ApplicationInterface

Add group/controller

Parameters

string $name
string|\Inhere\Console\Contract\ControllerInterface $class

The controller class

null|array|string $option

Returns

\Inhere\Console\Application|\Inhere\Console\Contract\ApplicationInterface

addController()

addController(string  $name, string|\Inhere\Console\Contract\ControllerInterface  $class = null, null|array|string  $option = null) : \Inhere\Console\Application|\Inhere\Console\Contract\ApplicationInterface

Parameters

string $name
string|\Inhere\Console\Contract\ControllerInterface $class

The controller class

null|array|string $option

Returns

\Inhere\Console\Application|\Inhere\Console\Contract\ApplicationInterface

controllers()

controllers(array  $controllers) 

Parameters

array $controllers

Throws

\InvalidArgumentException

setControllers()

setControllers(array  $controllers) 

Parameters

array $controllers

Throws

\InvalidArgumentException

addControllers()

addControllers(array  $controllers) 

Parameters

array $controllers

Throws

\InvalidArgumentException

command()

command(\Inhere\Console\string  $name,   $handler = null,   $option = null) 

{@inheritdoc}

Parameters

\Inhere\Console\string $name
$handler
$option

addCommand()

addCommand(string  $name, null  $handler = null, null  $option = null) : \Inhere\Console\Application

add command

Parameters

string $name
null $handler
null $option

Returns

\Inhere\Console\Application

addCommands()

addCommands(array  $commands) 

Parameters

array $commands

Throws

\InvalidArgumentException

commands()

commands(array  $commands) 

Parameters

array $commands

Throws

\InvalidArgumentException

registerCommands()

registerCommands(string  $namespace, string  $basePath) : $this

auto register commands from a dir.

$app->registerCommands('SwagPhp\Command', dirname(__DIR__) . '/src/Command');

Parameters

string $namespace
string $basePath

Throws

\InvalidArgumentException

Returns

$this

registerGroups()

registerGroups(string  $namespace, string  $basePath) : $this

auto register controllers from a dir.

Parameters

string $namespace
string $basePath

Throws

\InvalidArgumentException

Returns

$this

dispatch()

dispatch(\Inhere\Console\string  $name, \Inhere\Console\bool  $detachedRun = false) 

Parameters

\Inhere\Console\string $name
\Inhere\Console\bool $detachedRun

Throws

\ReflectionException
\InvalidArgumentException

getFileFilter()

getFileFilter() : \Closure

Returns

\Closure

runCommand()

runCommand(string  $name, \Closure|string  $handler, array  $options) : mixed

run a independent command

Parameters

string $name

Command name

\Closure|string $handler

Command class or handler func

array $options

Throws

\InvalidArgumentException

Returns

mixed

runAction()

runAction(string  $group, string  $action, mixed  $handler, array  $options, boolean  $detachedRun = false) : mixed

Execute an action in a group command(controller)

Parameters

string $group

The group name

string $action

Command method, no suffix

mixed $handler

The controller class or object

array $options
boolean $detachedRun

Throws

\ReflectionException

Returns

mixed