コード例 #1
0
ファイル: ApiManager.php プロジェクト: phxlol/lol-php-api
 /**
  * Init the API components
  */
 public function init()
 {
     $this->loop = Factory::create();
     // Catch signals
     $this->loop->addPeriodicTimer(1, function () {
         pcntl_signal_dispatch();
     });
     // Heartbeat, 2 minutes officially, here 5
     $this->loop->addPeriodicTimer(300, [$this, 'doHeartbeats']);
     // Clients logging
     if (true === ConfigurationLoader::get('client.async.enabled')) {
         $this->loop->addPeriodicTimer(0.5, function () {
             LoggerFactory::subscribe();
         });
     }
     // Init router
     $this->router = new Router();
     $this->router->init();
     // Init redis
     $this->redis = new Client(sprintf('tcp://%s:%d', ConfigurationLoader::get('client.async.redis.host'), ConfigurationLoader::get('client.async.redis.port')));
     // Async processes
     if (true === ConfigurationLoader::get('client.async.enabled')) {
         $this->clean(true);
         $this->catchSignals();
     } else {
         $this->logger->warning('You use the slow mode (synchronous), you can use the fast mode (asynchronous) by setting the configuration "client.async.enabled" to "true"');
     }
 }
コード例 #2
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeSection($output, 'Router : dump');
     $router = new Router();
     $router->init();
     $routes = $router->getRoutes();
     foreach ($routes as $controller => $methods) {
         $output->writeln(sprintf('<info>%s</info> : ', $controller));
         foreach ($methods as $method => $params) {
             $output->writeln(sprintf("  - <comment>%s</comment> :%s", $method, $this->formatParameters($method, $params)));
         }
     }
 }