TestAutoDiscoveryCommand.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace App\Module\Test\Commands;
  3. use Illuminate\Console\Command;
  4. /**
  5. * 测试Test模块的自动发现机制
  6. *
  7. * 这个命令没有在ServiceProvider中手动注册,用于验证自动发现是否工作
  8. */
  9. class TestAutoDiscoveryCommand extends Command
  10. {
  11. /**
  12. * 命令签名
  13. */
  14. protected $signature = 'test:auto-discovery {--count=5 : 要显示的数字数量}';
  15. /**
  16. * 命令描述
  17. */
  18. protected $description = '测试Test模块的命令自动发现机制 - 此命令未手动注册';
  19. /**
  20. * 执行命令
  21. */
  22. public function handle(): int
  23. {
  24. $count = (int) $this->option('count');
  25. $this->info('🚀 Test模块自动发现机制测试');
  26. $this->line('');
  27. $this->info("✨ 这个命令没有在ServiceProvider中手动注册!");
  28. $this->info("🔍 如果您能看到这条消息,说明自动发现机制工作正常!");
  29. $this->line('');
  30. $this->comment("生成 {$count} 个随机数字:");
  31. for ($i = 1; $i <= $count; $i++) {
  32. $number = rand(1, 100);
  33. $this->line(" {$i}. {$number}");
  34. }
  35. $this->line('');
  36. $this->info('🎉 Test模块命令自动发现机制测试成功!');
  37. return 0;
  38. }
  39. }