Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ioanandrei's avatar

Exception with no request or session

In Exceptions/Handler.php i added some logic to send an email with every exception from my flow ( i added this to report method ).

In my flow i have severals forms and from time to time i get an email with an error in file RouteCollection, line 255: MethodNotAllowedHttpException;

The url is this: mydomain.com/preorder/{someId} and the route is POST.

I get several emails with an error in file RouteCollection, line 255 on this route, but i don't have any request details or session details ( i get them in exception handler and send them in email ).

I reproduced this error trying to get to that route via get ( writing the url directly into the browser ).

My question is...there's any chance i could get this error with no request and session details in any other way? Beacuse, the user should have several informations stored in session in this point.

Beside that, i get several errors from someone who's trying to access mydomain.com/wp-admin or /wp-login and stuff like this, so i'm thinking maybe it's a BOT that's trying several routes.

What do you think?

0 likes
2 replies
ftiersch's avatar

I think that exception is thrown before your session is even started (but not totally sure) because it happens while Laravel tries to determine which route to send the user to. And because it can't find a route with the given method it throws an exception.

Could absolutely be a bot, yes. If you're sure you're only sending POST requests to that route that's probably very likely. But remember if you redirect to that route it will also be a GET request - maybe that's the problem. (a redirect()->back() or something like that).

ioanandrei's avatar

Thank you very much for the response! As a hot fix I changed a little bit my logic and now the route is GET and i will redirect the user if he dosn't have all the information he needs.

Please or to participate in this conversation.