easyswoole 898 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use EasySwoole\EasySwoole\Command\CommandRunner;
  3. use EasySwoole\Command\Caller;
  4. $file = __DIR__ . '/vendor/autoload.php';
  5. if (file_exists($file)) {
  6. require $file;
  7. } else {
  8. die("include composer autoload.php fail\n");
  9. }
  10. $realCwd = substr(realpath($file),0,-strlen("/vendor/autoload.php"));
  11. defined('IN_PHAR') or define('IN_PHAR', boolval(\Phar::running(false)));
  12. defined('RUNNING_ROOT') or define('RUNNING_ROOT', $realCwd);
  13. defined('EASYSWOOLE_ROOT') or define('EASYSWOOLE_ROOT', IN_PHAR ? \Phar::running() : $realCwd);
  14. if(file_exists(EASYSWOOLE_ROOT.'/bootstrap.php')){
  15. require_once EASYSWOOLE_ROOT.'/bootstrap.php';
  16. }
  17. $caller = new Caller();
  18. $caller->setScript(current($argv));
  19. $caller->setCommand(next($argv));
  20. $caller->setParams($argv);
  21. reset($argv);
  22. $ret = CommandRunner::getInstance()->run($caller);
  23. if($ret && !empty($ret->getMsg())){
  24. echo $ret->getMsg()."\n";
  25. }