public function dispatch() { try { $router = new Router($this->app); //ルーティングに沿ったcontrollerを設定 $router->routing(); $this->setNotFoundAction(); $this->app->handle(); } catch (\Exception $e) { throw $e; } catch (\Error $e) { throw $e; } }
public function handle($uri = null) { if ($this->apibird->corsEnabled()) { $this->options('^(/.*)$', function () { return ''; }); } return parent::handle($uri); }
try { /** * Read the configuration */ $config = (include __DIR__ . "/../config/config.php"); /** * Include Services */ include APP_PATH . '/config/services.php'; /** * Include Autoloader */ include APP_PATH . '/config/loader.php'; /** * Starting the application * Assign service locator to the application */ $app = new Micro($di); /** * Include Application */ include APP_PATH . '/app.php'; include APP_PATH . '/users.php'; include APP_PATH . '/todoEntries.php'; /** * Handle the request */ $app->handle(); } catch (\Exception $e) { echo $e->getMessage(); }
<?php error_reporting(E_ALL); use Phalcon\Mvc\Micro as App; define('APP_PATH', realpath('../app')); require APP_PATH . '/config/loader.php'; require APP_PATH . '/config/services.php'; //try { $app = new App(); $app->setDI($di); require APP_PATH . '/handlers.php'; $response = $app->handle(); if ($response instanceof Phalcon\Http\ResponseInterface) { $response->send(); } //} catch (Exception $e) { // echo $app->view->render('errors/500', array( // 'exception' => $e // )); //}
public function testMicroStopMiddlewareClasses() { $this->specify("Micro middleware events don't work as expected", function () { $app = new Micro(); $app->map("/api/site", function () { return true; }); $middleware = new \MyMiddlewareStop(); $app->before($middleware); $app->before($middleware); $app->after($middleware); $app->after($middleware); $app->finish($middleware); $app->finish($middleware); $app->handle("/api/site"); expect($middleware->getNumber())->equals(3); }); }
/** * Handle the whole restful request. * * @param string|null $uri * @return mixed * @throws \Parest\Exception\BuildException */ public function handle($uri = null) { try { if (!$this->hasService('access')) { throw new BuildException('The access service is not defined'); } $clientRole = call_user_func($this->_clientIdentificationHandler); if (!is_object($clientRole) || !$clientRole instanceof Role) { throw new BuildException('The client authorization handler return value is not a valid access role'); } $this->access->setClientRole($clientRole); return parent::handle($uri); } catch (ResourceException $e) { $e->response()->send(); } catch (BuildException $e) { throw $e; } catch (Exception $e) { $exception = new InternalServerErrorException(); $exception->response()->send(); } return false; }