Example #1
0
 /**
  * @return ServerInterface
  */
 public function getServer()
 {
     if (null === $this->server) {
         if (true === SwooleServer::isAvaiable()) {
             $this->server = $this->createSwooleServer();
         } elseif (true === ReactServer::isAvaiable()) {
             $this->server = $this->createReactServer();
         } else {
             throw new \BadMethodCallException('The server instance not avaiable!');
         }
     }
     return $this->server;
 }
 /**
  * @param ArrayNodeDefinition $rootNode
  */
 private function addServerSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->children()->arrayNode('server')->addDefaultsIfNotSet()->children()->scalarNode('default')->info('Alias of the default server')->defaultValue(SwooleServer::isAvaiable() ? 'swoole' : null)->end()->append($this->addSwooleServerNode())->end()->end()->end();
 }
 public function testDefalut()
 {
     $config = $this->createConfig(array());
     $this->assertEquals(array('server' => array('default' => SwooleServer::isAvaiable() ? 'swoole' : null, 'swoole' => array('enabled' => false, 'transformer' => array('use_server_request' => true, 'response_buffer' => 8096), 'options' => array())), 'request_handler' => array('default' => 'symfony'), 'exception_handler' => array('error_page' => array('template_path' => ErrorPageLoader::getDefaultTemplatePath())), 'executor' => array('default' => 'default', 'executorList' => array('default' => array('server' => ExecutorFactory::USE_DEFAULT_KEY, 'request_handler' => ExecutorFactory::USE_DEFAULT_KEY, 'exception_handler_service' => 'syrma.web_container.exception_handler', 'parent_service' => 'syrma.web_container.executor.abstract', 'use_factory' => true)))), $config);
 }