If you use a string callable for your routes, there is always one lookup performed BEFORE the route is dispatched. This means that as the number of routes you provide there is a slight overhead for the lookup.
It would be nice to refactor this so that the lookup is performed after the router has chosen a callable to dispatch.
public function map(array $methods, $pattern, $callable)
{
$callable = is_string($callable) ? $this->resolveCallable($callable) : $callable;
if ($callable instanceof Closure) {
$callable = $callable->bindTo($this);
}
$route = $this->container->get('router')->map($methods, $pattern, $callable);
if (is_callable([$route, 'setContainer'])) {
$route->setContainer($this->container);
}
if (is_callable([$route, 'setOutputBuffering'])) {
$route->setOutputBuffering($this->container->get('settings')['outputBuffering']);
}
return $route;
}
In the app class here... https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L236
If you use a string callable for your routes, there is always one lookup performed BEFORE the route is dispatched. This means that as the number of routes you provide there is a slight overhead for the lookup.
It would be nice to refactor this so that the lookup is performed after the router has chosen a callable to dispatch.