I’ve not long picked up Slim and I love it, but there’s one thing (so far!) I don’t like, which is the need to specify routes in some central place,
index.php, using something like
$app->get('/myroute', [SomeController::class, 'methodName']);
Is there a way of achieving the same thing, constructed differently? This way spreads information about
SomeController class and all its relatives into a central place, and requires manual updating when I want to add a new route.
What I’d like to do is to register the routes a controller supports from the controller or, maybe more preferably, from a class associated with each controller and the route methods are either discovered by that class or the controllers register their route-methods with .
The problem I’ve encountered is that it needs to happen before calling
$app->run() or at least before receiving a request. Has anyone tried using Doctrine Annotations to do this? I’m open to other ways, obviously, it was just an idea that came to me late last night (and so might be completely bonkers, especially since I’ve never used them before).