/** * Process the application given a request method and URI * * @param string $requestMethod the request method (e.g. GET, POST, etc.) * @param string $requestUri the request URI * @return \Yee\Http\Response */ public function runApp($requestMethod, $requestUri) { // Create a mock environment for testing with $environment = \Yee\Environment::mock(['REQUEST_METHOD' => $requestMethod, 'PATH_INFO' => $requestUri, 'REQUEST_URI' => $requestUri]); // Instantiate the application $app = new \Yee\Yee(array('version' => '0.0.0', 'debug' => false, 'mode' => 'testing')); $app->view(new \Yee\Views\Twig()); new \Yee\Managers\RoutingCacheManager(array('cache' => __DIR__ . '/../cache/routing', 'controller' => array(__DIR__ . '/../App/Controllers'))); $request = $app->request(); $response = $app->response(); ob_start(); $app->execute(); ob_end_clean(); return $response; }
<?php if (PHP_SAPI == 'cli-server') { // To help the built-in PHP dev server, check if the request was actually for // something which should probably be served as a static file $url = parse_url($_SERVER['REQUEST_URI']); $file = __DIR__ . $url['path']; if (is_file($file)) { return false; } } require __DIR__ . '/../vendor/autoload.php'; session_start(); // Instantiate the app $config = (require __DIR__ . '/../config.php'); $app = new \Yee\Yee($config); $app->view(new \Yee\Views\Twig()); new Yee\Managers\RoutingCacheManager(array('cache' => __DIR__ . '/../cache/routing', 'controller' => array(__DIR__ . '/../App/Controllers'))); // Run app $app->execute();