router icon indicating copy to clipboard operation
router copied to clipboard

[Feature request] Controller class/method not found scenario

Open mjoris opened this issue 4 years ago • 2 comments

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 😊

mjoris avatar Jan 06 '21 10:01 mjoris

Does this not cover what you need?

https://github.com/bramus/router#custom-404

WeaponsTheyFear avatar Jan 11 '21 07:01 WeaponsTheyFear

@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 ....

mjoris avatar Jan 11 '21 11:01 mjoris