public function test500() { $this->app->route('500', '/500', function () { throw new \Exception('Test Exception for 500'); }); $this->app->demand('header', function ($header) use(&$headers_list) { $headers_list[] = $header; }); $this->app->simulate_request('/500'); var_dump($headers_list); $this->assertNotEmpty($headers_list); $this->assertContains('HTTP/1.1 500 Internal Server Error', $headers_list); }
public function run(App $app) { foreach ($this->handlers as $handler) { ob_start(); $result = $app->exec_params($handler); $output = ob_get_clean(); if (!$result) { $result = $output; } if ($result) { return $result; } } return false; }
<?php use Microsite\App; use Microsite\Regex; use Microsite\Response; use Microsite\Request; use Microsite\DB\PDO\DB; use Microsite\Handler; use Microsite\Template; use Microsite\Tinycode; use Microsite\Renderers\JSONRenderer; use Microsite\Renderers\MarkdownRenderer; use Microsite\DB\Mongo\DB as MongoDB; //include 'src/microsite.phar'; include 'src/stub2.php'; $app = new App(); // Assign a directory in which templates can be found for rendering $app->template_dirs = [__DIR__ . '/views']; /** * Basic home page. * Set the view to a home.php view provided in the view directory */ $app->route('home', '/', function (App $app) { return $app->response()->render('home.php'); }); /** * Simple string output. */ $app->route('string', '/string', function () { return "A response can be a simple string from inside a function"; });