FooCommand.php 580 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Command;
  4. use Hyperf\Command\Command as HyperfCommand;
  5. use Hyperf\Command\Annotation\Command;
  6. use Psr\Container\ContainerInterface;
  7. #[Command]
  8. class FooCommand extends HyperfCommand
  9. {
  10. public function __construct(protected ContainerInterface $container)
  11. {
  12. parent::__construct('demo:command');
  13. }
  14. public function configure()
  15. {
  16. parent::configure();
  17. $this->setDescription('Hyperf Demo Command');
  18. }
  19. public function handle()
  20. {
  21. $this->line('Hello Hyperf!', 'info');
  22. }
  23. }