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

GTHell's avatar

Tutorial on how to debug Laravel like a pro?

I'm burnt out trying solving a bug because I don't know how to debug it. It was with my mailable class and my ajax form. There's not much I can do beside return back to console.log on frontend. But if it 500 then I'm stuck. I have multiple class and it's hard to keep track of. Without proper errors message, it would take me so many hours just to find out what the problems is.

Internal errors will return status code 500 + MethodNotAllowException. How do I send the real errors like (Cannot convert string to int exception or something similar) instead of MethodNotAllowException?

0 likes
15 replies
Sergiu17's avatar

Open Network Tab with when you dealing with AJAX Requests, 500 means Server error and Method No Allow Exception is - let's say you have a GET route, when you send a POST request to it, you get this exception, and not only POST, PUT and DELETE and any other HTTP request - but not GET. And this exception causes that 500 error :)

console log all the data you send, then dd() data from the request, if everything is OK, move to next step, save, or delete, or whatever, good luck!

Don't forget about storage/logs/laravel.log

2 likes
Snapey's avatar

If you are on V5.7 (and it is quite easy to upgrade so why not) then there is something called a dump server available.

You run this as a command with php artisan dump-server

The command keeps running and if your application throws an error, it will be output in this console window instead of being sent to the client.

You can also use dump() in your code if you want to check progress or inspect variables at any point in your code.

rawilk's avatar

I've recently started using Laravel Debugbar and it's been really helpful with debugging and optimizing queries.

1 like
GTHell's avatar

@Sergiu77 dd() everything into console.log() is cool until it return the entire page and have no idea what the log is all about.

@Snapey Can Laravel be update from v5.5 without affecting my code?

@wilk_randall adding that package make me feel that everything bloated. I never put much effort into it.

Snapey's avatar

Thats not something I can answer, it depends if you are using any changed features.

The upgrade instructions take you through it.

You will also need php 7.1

1 like
amancuker's avatar

@Snapey Did you use xdebug? Can you explain steps to debug laravel with xdebug pls?

amancuker's avatar

@Tray2 Reading and doing is NOT same thing! Did you set up it? It does not work for me I have googled it many times that is why I am asking it in here! You can read 50 times without doing it actually! Everyone can share link, but if you did not set up this yourself that does not matter!

Snapey's avatar

@amancuker then ask a question. Stop bumping very old threads, and don't call people out that have no interest in your problem

Please or to participate in this conversation.