webman 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env php
  2. <?php
  3. use Webman\Config;
  4. use Webman\Console\Command;
  5. use Webman\Console\Util;
  6. require_once __DIR__ . '/vendor/autoload.php';
  7. if (!in_array($argv[1] ?? '', ['start', 'restart', 'stop', 'status', 'reload', 'connections'])) {
  8. require_once __DIR__ . '/support/bootstrap.php';
  9. } else {
  10. if (class_exists('Support\App')) {
  11. Support\App::loadAllConfig(['route']);
  12. } else {
  13. Config::reload(config_path(), ['route', 'container']);
  14. }
  15. }
  16. $cli = new Command();
  17. $cli->setName('webman cli');
  18. $cli->installInternalCommands();
  19. if (is_dir($command_path = Util::guessPath(app_path(), '/command', true))) {
  20. $cli->installCommands($command_path);
  21. }
  22. foreach (config('plugin', []) as $firm => $projects) {
  23. if (isset($projects['app'])) {
  24. if ($command_str = Util::guessPath(base_path() . "/plugin/$firm", 'command')) {
  25. $command_path = base_path() . "/plugin/$firm/$command_str";
  26. $cli->installCommands($command_path, "plugin\\$firm\\$command_str");
  27. }
  28. }
  29. foreach ($projects as $name => $project) {
  30. if (!is_array($project)) {
  31. continue;
  32. }
  33. foreach ($project['command'] ?? [] as $command) {
  34. $cli->add(new $command);
  35. }
  36. }
  37. }
  38. $cli->run();