alternative controller design
-
Steve Clay
Another option would be to autoload only the controller file that matches the first word in the URI. This could be done in run() directly before the call to route_find(), so that dispatch* functions could be placed in the controller files.
Both these options would make controllers more re-usable, and load fewer files per request.
-
Fabrice Luraine
About loading the controller file that matches only the first word in URI, it can be done by defining your own
autoload_controllerfunction.function autoload_controller($callback) { $uri = request_uri(); // ... find first word in uri // then load the matching controller }I like the idea you illustrate before, some kind of default routes for a resource. But I think this should be left optionnal, keeping Limonade more versatile and not as opiniated.
Perhaps by defining a user definable functiondefault_routescalled inroute_findif no route found:function default_routes($method, $path) { // try checking a controller file foo.php... // return false or a route array... }
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
