CreateMiddleware
extends BaseCommand
in package
For Creating a new middleware in the middlewares directory by running `pionia gen:middleware {name}`
Tags
Table of Contents
Properties
- $aliases : array<string|int, mixed>
- The default aliases of the command.
- $description : string
- The default description of the command.
- $help : string
- The default help of the command.
- $hidden : bool
- The default hidden status of the command.
- $input : InputInterface
- The input interface implementation.
- $macros : array<string|int, mixed>
- $name : string
- The default name of the command.
- $output : OutputStyle
- The output interface implementation.
- $signature : string
- The default signature of the command.
- $title : string
- $verbosity : int
- The default verbosity of output commands.
- $verbosityMap : array<string|int, mixed>
- The mapping between human readable verbosity levels and Symfony's OutputInterface.
- $app : PioniaApplication|null
Methods
- __call() : mixed
- Dynamically handle calls to the class.
- __callStatic() : mixed
- Dynamically handle calls to the class.
- __construct() : mixed
- alert() : void
- Write a string in an alert box.
- anticipate() : mixed
- Prompt the user for input with auto completion.
- argument() : array<string|int, mixed>|string|bool|null
- Get the value of a command argument.
- arguments() : array<string|int, mixed>
- Get all of the arguments passed to the command.
- ask() : mixed
- Prompt the user for input.
- askWithCompletion() : mixed
- Prompt the user for input with auto completion.
- call() : int
- Call another console command.
- callCommand() : int
- callSilent() : int
- Call another console command without output.
- callSilently() : int
- Call another console command without output.
- choice() : string|array<string|int, mixed>
- Give the user a single choice from an array of answers.
- comment() : void
- Write a string as comment output.
- confirm() : bool
- Confirm a question with the user.
- error() : void
- Write a string as error output.
- flushMacros() : void
- Remove all the macros we had registered
- generate() : void
- getApp() : PioniaApplication|null
- getArguments() : array<string|int, mixed>
- getOutput() : OutputStyle
- Get the output implementation.
- hasArgument() : bool
- Determine if the given argument is present.
- hasMacro() : bool
- Check if we have a method in the balonables
- hasOption() : bool
- Determine if the given option is present.
- info() : void
- Write a string as information output.
- line() : void
- Write a string as standard output.
- macro() : void
- Add a new mixable to the macros
- mixin() : void
- Mix another object into the class.
- newLine() : $this
- Write a blank line.
- option() : string|array<string|int, mixed>|bool|null
- Get the value of a command option.
- options() : array<string|int, mixed>
- Get all of the options passed to the command.
- question() : void
- Write a string as question output.
- resolveCommandNameFromClassName() : string
- Automatically set the command name from the class name.
- secret() : mixed
- Prompt the user for input but hide the answer from the console.
- setInput() : void
- Set the input interface implementation.
- setOutput() : void
- Set the output interface implementation.
- table() : void
- Format input to textual table.
- warn() : void
- Write a string as warning output.
- withProgressBar() : int|iterable<string|int, mixed>|void
- Execute a given callback while advancing a progress bar.
- context() : array<string|int, mixed>
- Get all of the context passed to the command.
- createInputFromArguments() : ArrayInput
- Create an input instance from the given arguments.
- execute() : int
- Execute the console command.
- getOptions() : array<string|int, mixed>
- Get the console command options.
- handle() : int
- parseVerbosity() : int
- Get the verbosity level in terms of Symfony's OutputInterface level.
- resolveCommand() : Command
- Resolve the console command instance for the given command.
- runCommand() : int
- Run the given the console command.
- setVerbosity() : void
- Set the verbosity level.
- specifyParameters() : void
- Specify the arguments and options on the command.
- addActionMethods() : void
- setApp() : void
Properties
$aliases
The default aliases of the command.
protected
array<string|int, mixed>
$aliases
= ['g:m', 'gen:mid', 'gen:mid', 'gen:middle', 'gen:middleware']
$description
The default description of the command.
protected
string
$description
= 'Generates a middleware for a pionia app. Middlewares run on every request and response.'
$help
The default help of the command.
protected
string
$help
= 'Generates a middleware for a pionia app. Middlewares run on every request and response. \\n
Middlewares are added to the middleware chain automatically. Upon creation, you can add your logic to the middleware class and register it in the middleware sections of the settings file.'
$hidden
The default hidden status of the command.
protected
bool
$hidden
= false
$input
The input interface implementation.
protected
InputInterface
$input
$macros
protected
static array<string|int, mixed>
$macros
= []
$name
The default name of the command.
protected
string
$name
= 'make:middleware'
$output
The output interface implementation.
protected
OutputStyle
$output
$signature
The default signature of the command.
protected
string
$signature
$title
protected
string
$title
= 'Adds a new middleware to pionia app'
$verbosity
The default verbosity of output commands.
protected
int
$verbosity
= \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL
$verbosityMap
The mapping between human readable verbosity levels and Symfony's OutputInterface.
protected
array<string|int, mixed>
$verbosityMap
= ['v' => \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERBOSE, 'vv' => \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_VERY_VERBOSE, 'vvv' => \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_DEBUG, 'quiet' => \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_QUIET, 'normal' => \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL]
$app
private
PioniaApplication|null
$app
Methods
__call()
Dynamically handle calls to the class.
public
__call(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
__callStatic()
Dynamically handle calls to the class.
public
static __callStatic(string $method, array<string|int, mixed> $parameters) : mixed
Parameters
- $method : string
- $parameters : array<string|int, mixed>
Tags
__construct()
public
__construct([PioniaApplication|null $app = null ]) : mixed
Parameters
- $app : PioniaApplication|null = null
alert()
Write a string in an alert box.
public
alert(string $string[, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $verbosity : int|string|null = null
anticipate()
Prompt the user for input with auto completion.
public
anticipate(string $question, callable|array<string|int, mixed> $choices[, string|null $default = null ]) : mixed
Parameters
- $question : string
- $choices : callable|array<string|int, mixed>
- $default : string|null = null
argument()
Get the value of a command argument.
public
argument([string|null $key = null ]) : array<string|int, mixed>|string|bool|null
Parameters
- $key : string|null = null
Return values
array<string|int, mixed>|string|bool|nullarguments()
Get all of the arguments passed to the command.
public
arguments() : array<string|int, mixed>
Return values
array<string|int, mixed>ask()
Prompt the user for input.
public
ask(string $question[, string|null $default = null ]) : mixed
Parameters
- $question : string
- $default : string|null = null
askWithCompletion()
Prompt the user for input with auto completion.
public
askWithCompletion(string $question, callable|array<string|int, mixed> $choices[, string|null $default = null ]) : mixed
Parameters
- $question : string
- $choices : callable|array<string|int, mixed>
- $default : string|null = null
call()
Call another console command.
public
call(string|Command $command[, array<string|int, mixed> $arguments = [] ]) : int
Parameters
- $command : string|Command
- $arguments : array<string|int, mixed> = []
Return values
intcallCommand()
public
callCommand(array<string|int, mixed> $arguments[, Closure|null $postRun = null ]) : int
Parameters
- $arguments : array<string|int, mixed>
- $postRun : Closure|null = null
Tags
Return values
intcallSilent()
Call another console command without output.
public
callSilent(Command|string $command[, array<string|int, mixed> $arguments = [] ]) : int
Parameters
- $command : Command|string
- $arguments : array<string|int, mixed> = []
Return values
intcallSilently()
Call another console command without output.
public
callSilently(string|Command $command[, array<string|int, mixed> $arguments = [] ]) : int
Parameters
- $command : string|Command
- $arguments : array<string|int, mixed> = []
Return values
intchoice()
Give the user a single choice from an array of answers.
public
choice(string $question, array<string|int, mixed> $choices[, int|string|null $default = null ][, mixed|null $attempts = null ][, bool $multiple = false ]) : string|array<string|int, mixed>
Parameters
- $question : string
- $choices : array<string|int, mixed>
- $default : int|string|null = null
- $attempts : mixed|null = null
- $multiple : bool = false
Return values
string|array<string|int, mixed>comment()
Write a string as comment output.
public
comment(string $string[, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $verbosity : int|string|null = null
confirm()
Confirm a question with the user.
public
confirm(string $question[, bool $default = false ]) : bool
Parameters
- $question : string
- $default : bool = false
Return values
boolerror()
Write a string as error output.
public
error(string $string[, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $verbosity : int|string|null = null
flushMacros()
Remove all the macros we had registered
public
static flushMacros() : void
generate()
public
generate(string $className) : void
Parameters
- $className : string
getApp()
public
getApp() : PioniaApplication|null
Return values
PioniaApplication|nullgetArguments()
public
getArguments() : array<string|int, mixed>
Return values
array<string|int, mixed>getOutput()
Get the output implementation.
public
getOutput() : OutputStyle
Return values
OutputStylehasArgument()
Determine if the given argument is present.
public
hasArgument(int|string $name) : bool
Parameters
- $name : int|string
Return values
boolhasMacro()
Check if we have a method in the balonables
public
static hasMacro(string $name) : bool
Parameters
- $name : string
Return values
boolhasOption()
Determine if the given option is present.
public
hasOption(string $name) : bool
Parameters
- $name : string
Return values
boolinfo()
Write a string as information output.
public
info(string $string[, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $verbosity : int|string|null = null
line()
Write a string as standard output.
public
line(string $string[, string|null $style = null ][, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $style : string|null = null
- $verbosity : int|string|null = null
macro()
Add a new mixable to the macros
public
static macro(string $key, $value) : void
Parameters
mixin()
Mix another object into the class.
public
static mixin(object $mixin[, bool $replace = true ]) : void
Parameters
- $mixin : object
- $replace : bool = true
Tags
newLine()
Write a blank line.
public
newLine([int $count = 1 ]) : $this
Parameters
- $count : int = 1
Return values
$thisoption()
Get the value of a command option.
public
option([string|null $key = null ]) : string|array<string|int, mixed>|bool|null
Parameters
- $key : string|null = null
Return values
string|array<string|int, mixed>|bool|nulloptions()
Get all of the options passed to the command.
public
options() : array<string|int, mixed>
Return values
array<string|int, mixed>question()
Write a string as question output.
public
question(string $string[, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $verbosity : int|string|null = null
resolveCommandNameFromClassName()
Automatically set the command name from the class name.
public
resolveCommandNameFromClassName() : string
Return values
stringsecret()
Prompt the user for input but hide the answer from the console.
public
secret(string $question[, bool $fallback = true ]) : mixed
Parameters
- $question : string
- $fallback : bool = true
setInput()
Set the input interface implementation.
public
setInput(InputInterface $input) : void
Parameters
- $input : InputInterface
setOutput()
Set the output interface implementation.
public
setOutput(OutputStyle $output) : void
Parameters
- $output : OutputStyle
table()
Format input to textual table.
public
table(array<string|int, mixed> $headers, array<string|int, mixed>|Arrayable $rows[, string|TableStyle $tableStyle = 'default' ][, array<string|int, mixed> $columnStyles = [] ]) : void
Parameters
- $headers : array<string|int, mixed>
- $rows : array<string|int, mixed>|Arrayable
- $tableStyle : string|TableStyle = 'default'
- $columnStyles : array<string|int, mixed> = []
warn()
Write a string as warning output.
public
warn(string $string[, int|string|null $verbosity = null ]) : void
Parameters
- $string : string
- $verbosity : int|string|null = null
withProgressBar()
Execute a given callback while advancing a progress bar.
public
withProgressBar(iterable<string|int, mixed>|int $totalSteps, Closure $callback) : int|iterable<string|int, mixed>|void
Parameters
- $totalSteps : iterable<string|int, mixed>|int
- $callback : Closure
Return values
int|iterable<string|int, mixed>|voidcontext()
Get all of the context passed to the command.
protected
context() : array<string|int, mixed>
Return values
array<string|int, mixed>createInputFromArguments()
Create an input instance from the given arguments.
protected
createInputFromArguments(array<string|int, mixed> $arguments) : ArrayInput
Parameters
- $arguments : array<string|int, mixed>
Return values
ArrayInputexecute()
Execute the console command.
protected
execute(InputInterface $input, OutputInterface $output) : int
Parameters
- $input : InputInterface
- $output : OutputInterface
Return values
intgetOptions()
Get the console command options.
protected
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>handle()
protected
handle() : int
Return values
intparseVerbosity()
Get the verbosity level in terms of Symfony's OutputInterface level.
protected
parseVerbosity([int|string|null $level = null ]) : int
Parameters
- $level : int|string|null = null
Return values
intresolveCommand()
Resolve the console command instance for the given command.
protected
abstract resolveCommand(string|Command $command) : Command
Parameters
- $command : string|Command
Return values
CommandrunCommand()
Run the given the console command.
protected
runCommand(Command|string $command, array<string|int, mixed> $arguments, OutputInterface $output) : int
Parameters
- $command : Command|string
- $arguments : array<string|int, mixed>
- $output : OutputInterface
Tags
Return values
intsetVerbosity()
Set the verbosity level.
protected
setVerbosity(int|string $level) : void
Parameters
- $level : int|string
specifyParameters()
Specify the arguments and options on the command.
protected
specifyParameters() : void
addActionMethods()
private
addActionMethods(ClassType $class) : void
Parameters
- $class : ClassType
setApp()
private
setApp(PioniaApplication|null $app) : void
Parameters
- $app : PioniaApplication|null