/** * {@inheritdoc} */ public function execute(Request $request) { $start = microtime(true); $httpRequest = new HTTP\Request(); $body = new Body(); $httpResponse = new HTTP\Response(); $httpResponse->setBody($body); try { $result = $this->runCallback($httpRequest, $httpResponse); $body->append($result); } catch (\Exception $e) { $httpResponse->setResponseCode(500); //TODO: Maybe implement something more complex, with better error reporting? Error::printException($e, false); $body->append(sprintf('Error: %s', $e->getMessage())); } $this->prepareResponse($httpResponse); return $httpResponse->toArray(); }
protected function getLastError() { if ($e = parent::getLastError()) { return $e; } return array('type' => E_WARNING, 'message' => 'Foo Bar', 'file' => '/tmp/foo', 'line' => 2); }
<?php use Skeetr\Debugger; use Skeetr\Client; use Skeetr\Client\Socket; use Skeetr\Client\Handler\Error; use Monolog\Logger; use Monolog\Handler\StreamHandler; require __DIR__ . '/../vendor/autoload.php'; $logger = new Logger('debugger'); $logger->pushHandler(new StreamHandler('php://stdout', Logger::NOTICE)); Error::register(); Error::setLogger($logger); /* $debugger = new Debugger($logger); $debugger->run(); */ $socket = new Socket('/tmp/foo.sock'); $client = new Client($socket); $client->setLogger($logger); $client->setCallback(function ($request, $response) use($logger) { session_start(); if (!isset($_SESSION['count'])) { $_SESSION['count'] = 0; } $_SESSION['count']++; // throw new \Exception("Error Processing Request", 1); header('Foo: boo'); setcookie('foo', 'bar'); setcookie('baz', 'qux'); return 'test' . $_SESSION['count'];