What is the most appropriate way to debug your source code in Laravel?
An error message should speak about the cause. Least it should be convenient for the developer to track a the bug with some hints(like the name of file, a function, either in controller or model, or both or the view, etc.)
What about Laravel?
This is not the first time, there comes an issue almost everyday in the code(of course we love bugs, we’ll learn from it). What if you spend the whole day tracking a typo err? What if there is only a black board saying:
Better luck next time!!*
By default, the happiest framework is the ever worse to give accurate errors in the code. May be there is a method, may be that is what this question asks about.
php artisan r:l
[SymfonyComponentDebugExceptionFatalErrorException]
Fatal error: Namespace declaration statement has to be the very first
statement ..
.. so that says where the error is. Check all the Controllers & Models to find the the exception. That will only waste the time and still the same error. The server was started early morning and still running. Browser is working but not loading the page. This must have happened because of a recent change in a file but not sure exactly which one.
Another day, another one:
TokenMismatchException in VerifyCsrfToken …
So far I know of 5 possible cases that will lead to this error. Not going to list em’ all. Almost every time it only kills my time, at the end I realize it was not worth 5 mins.
————————————————————————–
- Now what is the solution? How is it possible to track such an bug
with the Laravel core tools? In other way, how is it possible for a
Laravel5 website to show accurate errors? - How could I handle exceptions in Laravel? Which file(class) may help
me to work on it if I wish to arrange such a platform (that always
tells me what/where exactly the problem is) before I start working on
a fresh L5 copy? - I started from Laravel v5.2 only. Hope there won’t be much difference
in other earlier and later versions. What about them? - And most importantly, how is it possible to track errors from the console
while the server is running in the background? Anyphp artisan ..
command(s)?
[After dinner I found the bug(Namespace declaration) was with a route that spelled wrong and so was not redirecting to the proper view from the controller! BAD TYPO]
from Laravel Questions and Answers https://laravelquestions.com/php/what-is-the-most-appropriate-way-to-debug-your-source-code-in-laravel/
via Lzo Media
No comments:
Post a Comment