ArgvInput
class ArgvInput extends Input
ArgvInput represents an input coming from the CLI arguments.
Usage:
$input = new ArgvInput();
By default, the $_SERVER['argv']
array is used for the input values.
This can be overridden by explicitly passing the input values in the constructor:
$input = new ArgvInput($_SERVER['argv']);
If you pass it yourself, don't forget that the first element of the array is the name of the running application.
When passing an argument to the constructor, be sure that it respects
the same rules as the argv one. It's almost always better to use the
StringInput
when you want to provide your own input.
Properties
protected | $definition | from Input | |
protected | $stream | from Input | |
protected | $options | from Input | |
protected | $arguments | from Input | |
protected | $interactive | from Input |
Methods
Binds the current Input instance with the given arguments and options.
Processes command line arguments.
Returns the argument value for a given argument name.
Returns true if an InputArgument object exists by name or position.
Returns the option value for a given option name.
Escapes a token through escapeshellarg if it contains unsafe chars.
Sets the input stream to read from when interacting with the user.
No description
Returns the first argument from the raw parameters (not parsed).
Returns true if the raw parameters (not parsed) contain a value.
Returns the value of a raw option (not parsed).
Returns a stringified representation of the args passed to the command.
Details
bind(InputDefinition $definition)
Binds the current Input instance with the given arguments and options.
string|string[]|null
getArgument(string $name)
Returns the argument value for a given argument name.
bool
hasArgument(string|int $name)
Returns true if an InputArgument object exists by name or position.
string
escapeToken(string $token)
Escapes a token through escapeshellarg if it contains unsafe chars.
setStream(resource $stream)
Sets the input stream to read from when interacting with the user.
This is mainly useful for testing purpose.
bool
hasParameterOption(string|array $values, bool $onlyParams = false)
Returns true if the raw parameters (not parsed) contain a value.
This method is to be used to introspect the input parameters before they have been validated. It must be used carefully. Does not necessarily return the correct result for short options when multiple flags are combined in the same option.
mixed
getParameterOption(string|array $values, mixed $default = false, bool $onlyParams = false)
Returns the value of a raw option (not parsed).
This method is to be used to introspect the input parameters before they have been validated. It must be used carefully. Does not necessarily return the correct result for short options when multiple flags are combined in the same option.