Download the PHP package fyre/command without Composer
On this page you can find all versions of the php package fyre/command. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package command
FyreCommand
FyreCommand is a free, open-source CLI command library for PHP.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Commands
- Aliases
- Options
Installation
Using Composer
In PHP:
Basic Usage
$container
is a Container.$inflector
is an Inflector.$loader
is a Loader.$io
is a Console.$eventManager
is an EventManager.$typeParser
is an TypeParser.
Autoloading
It is recommended to bind the CommandRunner to the Container as a singleton.
Any dependencies will be injected automatically when loading from the Container.
Methods
Add Namespace
Add a namespace for loading commands.
$namespace
is a string representing the namespace.
All
Get all available commands.
Clear
Clear all namespaces and loaded commands.
Get Namespaces
Get the namespaces.
Handle
Handle an argv Command.
$argv
is an array containing the CLI arguments.
Has Command
Determine whether a command exists.
$alias
is a string representing the command alias.
Has Namespace
Determine whether a namespace exists.
$namespace
is a string representing the namespace.
Remove Namespace
Remove a namespace.
$namespace
is a string representing the namespace.
Run
Run a Command.
$alias
is a string representing the command alias.$arguments
is an array containing arguments for the command, and will default to [].
Command options will be parsed from the provided arguments.
Commands
Custom commands can be created by extending \Fyre\Command\Command
, suffixing the class name with "Command", and ensuring a run
method is implemented.
Any dependencies will be resolved automatically from the Container.
The run
method should return an integer representing the command exit code. The class constants Command::CODE_SUCCESS
and Command::CODE_ERROR
can be used.
Aliases
You can define $alias
and $description
properties on the command. If no $alias
is a provided, the command class name will be used (converted to snake_case).
Options
You can also define an $options
array on your custom commands, which will be used by the CommandRunner to parse the arguments and prompt for input if required.
prompt
is a string representing the prompt text, and will default to "".values
is an array containing the values, and will default to null.required
is a boolean indicating whether a value must be provided, and will default to false.as
is a string representing the value type, and will default to null.default
is the default value, and will default to true.
If an option is marked as required
and not provided as an argument, the CommandRunner will prompt for the value, otherwise the default
value will be used.
All versions of command with dependencies
fyre/container Version ^1.0
fyre/event Version ^4.0
fyre/inflector Version ^3.0
fyre/loader Version ^3.0
fyre/typeparser Version ^5.0