addErrorMiddleware(true, true, true); // Add BasePath $app->setBasePath(getBasePath()); // Add routes $app->get('/', function (Request $request, Response $response) use($app) { $response->getBody()->write('Try /hello/world'); return $response; }); $app->get('/hello/{name}', function (Request $request, Response $response, $args) { $name = $args['name']; $response->getBody()->write("Hello, $name"); return $response; }); $app->run(); // Get Base Path function getBasePath() { $basePath = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); if ($basePath == '/') return ''; return $basePath; }