コード例 #1
0
ファイル: Application.php プロジェクト: spajak/flow
 /**
  * Class constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this['debug'] = true;
     $this['logger'] = function ($app) {
         return new Logger('app', [new StreamHandler('php://stdout')]);
     };
     $this['console'] = function ($app) {
         return new Console();
     };
     $this['dispatcher'] = function ($app) {
         $dispatcher = new Dispatcher();
         $dispatcher->setLogger($app['logger']);
         $dispatcher->addLayer(new RouteMiddlewareLayer('route', $app));
         $dispatcher->addLayer(new MiddlewareLayer('default'));
         return $dispatcher;
     };
     $this['server'] = function ($app) {
         $server = new Server();
         $server->setLogger($app['logger']);
         $server->setDispatcher($app['dispatcher']);
         return $server;
     };
     $this['request'] = function ($app) {
         return $app['server']->getRequest();
     };
     $this['route'] = null;
 }
コード例 #2
0
ファイル: ServerTest.php プロジェクト: spajak/flow
 /**
  * @expectedException RuntimeException
  * @expectedExceptionMessageRegExp /Server/i
  */
 public function testListenInvalidResponse()
 {
     $dispatcher = new SimpleDispatcher();
     $dispatcher->mount('test', function () {
     });
     $server = new Server();
     $server->setDispatcher($dispatcher);
     $server->listen();
 }