You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems not a big issue, but I thought I'd report it anyway.
When you make a GET request to a page that does not exist, which should prompt a 404, and there are no defined GET routes, then you get this error message:
"Undefined array key "GET" in /vendor/bramus/router/src/Bramus/Router/Router.php on line 292"
If you define a GET route just as a placeholder. The error disappears.
Same situation is valid for POST requests.
Example:
$router = new \Bramus\Router\Router();
$router->set404(function () {
header('HTTP/1.1 404 Not Found');
echo'404: Page not found!';
});
$router->post('/upload', function () {
// some code
});
$router->run();
Make a GET request (just browse) to any url other than "/upload" to trigger a 404 and I get the error message I mentioned above.
Workaround I am using:
$router->match('GET|POST', '/get-post-route-placeholder', function () {
// This Route is here so that there is at least one GET and one POST route defined.
// When there is no GET or no POST routes, a GET or POST request to a non-existing URL that triggers set404() prompts an error:
// Undefined array key "GET"(or "POST") in /vendor/bramus/router/src/Bramus/Router/Router.php on line 292
});
Did not test any other HTTP methods.
bramus/router is version 1.6.1 installed via composer.
PHP 8.1.2 on Ubuntu 22.04.
The text was updated successfully, but these errors were encountered:
"Undefined array key "GET" in /vendor/bramus/router/src/Bramus/Router/Router.php on line 292"
It is just a test, the idea is that the $router will be set before the hook and the $router will run just after the hook so multiple $routes can be set in the hook.
Hi,
This seems not a big issue, but I thought I'd report it anyway.
When you make a GET request to a page that does not exist, which should prompt a 404, and there are no defined GET routes, then you get this error message:
"Undefined array key "GET" in /vendor/bramus/router/src/Bramus/Router/Router.php on line 292"
If you define a GET route just as a placeholder. The error disappears.
Same situation is valid for POST requests.
Example:
Make a GET request (just browse) to any url other than "/upload" to trigger a 404 and I get the error message I mentioned above.
Workaround I am using:
Did not test any other HTTP methods.
bramus/router is version 1.6.1 installed via composer.
PHP 8.1.2 on Ubuntu 22.04.
The text was updated successfully, but these errors were encountered: