Default route arguments in Slim
A friend of mine recently asked how to do default route arguments and route specific configuration in Slim, so I thought I'd write up how to do it. Consider a simple Hello route: $app->get("/hello[/{name}]", function ($request, $response, $args) { $name = $request->getAttribute('name'); return $response->write("Hello $name"); }) This will display "Hello " for the URL /hello and "Hello Rob" for the URL /hello/Rob. If we wanted a default of "World", we can set an argument on… continue reading.