router
router copied to clipboard
[Feature request] Controller class/method not found scenario
bramus/router
is not only my favourite router for 'vanilla PHP' with great functionality, it is also great for education: we are using the router in our PHP labs because of its very clean and clear interface.
It would be nice if the router would do something else than showing a blank screen when the controller class or controller method is not found. I was thinking of either throwing an Error or returning some HTTP status code / message (but different from empty 404). It would make debugging easier for PHP students 😊
Does this not cover what you need?
https://github.com/bramus/router#custom-404
@WeaponsTheyFear no, of course not. if you have
$router->get('/test', 'NonExistingClass@whatever');
and browse to /test
, currently a blank page is shown (HTTP code 200), and the 404 handler is not triggered.
Triggering the 404 handler wouldn't be a good idea either, because the developer should be able to easily find out whether none of the route patterns match, or the class wasn't found, or the method was not available ....