自定义进程

  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->addProcess(function(){
  7. while (true) {
  8. sleep(1);
  9. $this->get(StdoutLoggerInterface::class)->info('Processing...');
  10. }
  11. });
  12. $app->run();