命令行

  1. <?php
  2. use Hyperf\Contract\StdoutLoggerInterface;
  3. use Hyperf\Nano\Factory\AppFactory;
  4. require_once __DIR__ . '/vendor/autoload.php';
  5. $app = AppFactory::create();
  6. $app->addCommand('echo', function(){
  7. $this->get(StdoutLoggerInterface::class)->info('A new command called echo!');
  8. });
  9. $app->run();

执行

  1. php index.php echo