xcat 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env php
  2. <?php
  3. declare(strict_types=1);
  4. use App\Services\Boot;
  5. require __DIR__ . '/app/predefine.php';
  6. require __DIR__ . '/vendor/autoload.php';
  7. require __DIR__ . '/config/.config.php';
  8. require __DIR__ . '/app/envload.php';
  9. Boot::setTime();
  10. Boot::bootSentry();
  11. Boot::bootDb();
  12. if (!isset($argv[1])) {
  13. $commandPath = BASE_PATH . '/src/Command/';
  14. $allCommandFiles = glob($commandPath . '*.php');
  15. $allCommands = str_replace(
  16. [
  17. $commandPath,
  18. '.php'
  19. ],
  20. [
  21. '\\App\\Command\\',
  22. ''
  23. ],
  24. $allCommandFiles
  25. );
  26. echo PHP_EOL;
  27. foreach ($allCommands as $commandClass) {
  28. if ($commandClass == '\\App\\Command\\Command') {
  29. continue;
  30. }
  31. if (!class_exists($commandClass)) {
  32. continue;
  33. }
  34. $triggerObject = new $commandClass($argv);
  35. if (!property_exists($triggerObject, 'description')) {
  36. continue;
  37. }
  38. echo trim($triggerObject->description) . PHP_EOL;
  39. }
  40. return;
  41. }
  42. $classPath = '\\App\\Command\\' . $argv[1];
  43. if (class_exists($classPath)) {
  44. $trigger = new $classPath($argv);
  45. $trigger->boot();
  46. } else {
  47. echo 'Unable to load class: ' . $classPath . PHP_EOL;
  48. }