The default command component of Hyperf provided by [hyperf/command](https://github.com/hyperf/command) component,And this component is a abstraction of [symfony/console](https://github.com/symfony/console).
This component usually exists by default, but if you want to use it for non-Hyperf projects, you can also rely on the [hyperf/command](https://github.com/hyperf/command) component with the following command:
If you have the [hyperf/devtool](https://github.com/hyperf/devtool) component installed, you can generate a custom command with the `gen:command` command:
There are three forms of commands that define the command class. The first is defined by the `$name` property, the second is defined by the constructor argument, and the last is defined by annotations. We demonstrate this through code examples, assuming we want to define the command. The class command is `foo:hello`:
The logic that the command class actually runs depends on the `handle` method inside the code, which means that the `handle` method is the entry point to the command.
// Output Hello Hyperf. in the Console via the built-in method line()
$this->line('Hello Hyperf.', 'info');
}
}
```
### Define the arguments of the command
When writing a command, the user's input is usually collected by `parameter` and `option`, and the `parameter` or `option` must be defined before collecting a user input.
#### Parameter
Suppose we want to define a `name` parameter, and then pass the arbitrary string such as `Hyperf` to the command and execute `php bin/hyperf.php foo:hello Hyperf` to output `Hello Hyperf`. Let's demonstrate it by code: