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

michalis's avatar

findorfail, @csrf and @method dont seem to work

been following along with the laravel from scratch series

findorfail leads to a NotFoundHttpException instead of a 404

and the blade helpers @csrf and @method dont work either they just appear on the page as text, when using the curly braces syntax they do work

im on v5.4, could that be the problem?

0 likes
5 replies
michalis's avatar

@edoc

thank you :)

is it the same with findOrFail? from my understand its not but still dont get why it doesnt work

ftiersch's avatar

The findOrFail works because it throws a NotFoundException. Just the Handling of the Exception is wrong. :)

You can check out the Handler class for that. Possibly that has changed too.

michalis's avatar

@ftiersch

I apologize, I do not understand, Im a novice. You are saying the handling is wrong, is it something that I did, something I can fix, or are you saying the difference in handling is due to the difference in the laravel versions

ftiersch's avatar

If findOrFail doesn't find the ID you are looking for it will throw a NotFoundHttpException. So that part works great.

Now that Exception needs to be handled. If it's not handled it will show a 500 server error because that is the default for all unhandled exceptions.

If you check out the class app/Exceptions/Handler you will see that that is where all the exceptions are handled by Laravel. Maybe you have changed something in there that doesn't convert the Exception into a 404 response :)

1 like

Please or to participate in this conversation.