/** * Set the routes * * @param array $routes Array of routes configurations * * @throws \Exception */ public function configureRoutes($routes) { $routeCollection = new RouteCollection(); foreach ($routes as $route) { if ($this->debug) { Log::write('Configuring route "' . $route['path'] . '"'); } $routeObject = $this->router->respond($route['httpMethod'], $route['path'], $route['callback']); $routeObject->setName($route['name']); $routeCollection->set($route['name'], $routeObject); } $this->router = new Klein($this->router->service(), $this->router->app(), $routeCollection); if ($this->debug) { // Add a catchall debugging route Log::write('Configuring catchall route'); $this->router->respond('*', function (Request $request, Response $response) { Log::write(' ==> URI called : "' . $request->uri() . '" / User Agent : "' . $request->userAgent() . '"'); Log::write(' <== Response code : ' . $response->code()); }); } }