public function init($path, $loader)
 {
     $host = \Group\Config\Config::get('app::swoole_host') ?: "127.0.0.1";
     $port = \Group\Config\Config::get('app::swoole_port') ?: 9777;
     $setting = \Group\Config\Config::get('app::swoole_setting');
     $http = new swoole_http_server($host, $port);
     $http->set($setting);
     $http->on('request', function ($request, $response) use($path, $loader) {
         $request->get = isset($request->get) ? $request->get : [];
         $request->post = isset($request->post) ? $request->post : [];
         $request->cookie = isset($request->cookie) ? $request->cookie : [];
         $request->files = isset($request->files) ? $request->files : [];
         $request->server = isset($request->server) ? $request->server : [];
         $request->server['REQUEST_URI'] = isset($request->server['request_uri']) ? $request->server['request_uri'] : '';
         preg_match_all("/^(.+\\.php)(\\/.*)\$/", $request->server['REQUEST_URI'], $matches);
         $request->server['REQUEST_URI'] = isset($matches[2]) ? $matches[2][0] : '';
         if ($request->server['request_uri'] == '/favicon.ico') {
             $response->end();
             return;
         }
         $this->fix_gpc_magic($request);
         $app = new App();
         $app->initSwoole($path, $loader, $request);
         $data = $app->handleSwooleHttp();
         $response->status($data->getStatusCode());
         $response->end($data->getContent());
         return;
     });
     $http->start();
 }
Exemple #2
0
 public function init($path, $loader)
 {
     $this->fix_gpc_magic();
     $app = new App();
     $app->init($path, $loader);
     $app->handleHttp();
 }
Exemple #3
0
<?php

/*
 * 单元测试入口
 */
use Group\App\App;
$loader = (require __DIR__ . '/../vendor/autoload.php');
$loader->setUseIncludePath(true);
$app = new App();
$app->initSelf();
$app->doBootstrap($loader);
$app->registerServices();