tc-php-mvc-core
tc-php-mvc-core copied to clipboard
Added findRoute() method to Router class
Think that our public/index.php file looks like this:
<?php
//...
$app->router->get('/test', [SiteController::class, 'test']);
//...
And now if we try to access route /test with method POST, then it will return 404 Not Found, which is not very good status for this case. The router should return 405 Method Not Allowed instead.
In this commit, I've added a method findRoute() which finds a route, and returns the route action, method and the URI.
@thecodeholic
Well it seems to have some problems with routes that includes params for ex. '/user/{username}' it will still throw not found