use Illuminate\Console\Command; class MyCommand extends Command { protected $name = 'my_command'; protected $description = 'Description of My Command.'; protected $signature = 'my_command {arg1} {--option1}'; public function __construct() { parent::__construct(); } public function handle() { // Logic for My Command. } }
use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; class YourCommand extends Command { protected $name = 'your_command'; protected $description = 'Description of Your Command.'; protected $signature = 'your_command {arg1} {--option1}'; public function __construct(InputOption $inputOption) { $this->addOption($inputOption); parent::__construct(); } public function handle() { // Logic for Your Command. } }In this example, we defined a new option when constructing the input for the command. Then, we added it to the command's signature by calling the addOption method. Package library: This code example also belongs to Laravel Framework, specifically the illuminate/console package.