Laravel Classroom image

To post your Question Join Classroom
Lesson Topics's No:-  |1 | 2 | 3|Last
Lessons:-Debugging Applications

Debugging Applications
Applications written using the Laravel framework are best experienced without bugs, however
we all know how easily they can arise when we have deadlines to meet, and angry bosses
standing over our shoulders.
PHP itself has a number of different methods of debugging, from simple var_dump()s, print_-
r()s, the famous die() and the advanced debugging features of the PHP xdebug extension. I’m
not going to cover these basic methods in detail, because this is a book about Laravel, not the
basics of the PHP language. Instead let’s have a look at the features that Laravel offers to help
us track down those mean little bugs.
23.1 Error Handler
Laravel includes a custom error handler, which overwrites the default one liner PHP errors, and
instead provides some greater detail along with a stacktrace. Let’s have a look at the output from
the error handler..
1 Unhandled Exception
3 Message:
5 View [page.panda] doesn't exist.
6 Location:
8 /Users/daylerees/www/panda/laravel/view.php on line 151
9 Stack Trace:
11 #0 /Users/daylerees/www/panda/laravel/view.php(93): Laravel\View->path('pag\
12 e.panda')
13 #1 /Users/daylerees/www/panda/laravel/view.php(199): Laravel\View->__constr\
14 uct(' page.panda ', Array)
15 #2 /Users/daylerees/www/panda/application/routes.php(35): Laravel\View::mak\
16 e(' page.panda ')
17 #3 [internal function]: {closure}()
18 #4 /Users/daylerees/www/panda/laravel/routing/route.php(163): call_user_fun\
19 c_array(Object(Closure), Array)
20 #5 /Users/daylerees/www/panda/laravel/routing/route.php(124): Laravel\Routi\
21 ng\Route->response()
22 #6 /Users/daylerees/www/panda/laravel/laravel.php(125): Laravel\Routing\Rou\
23 te->call()
24 #7 /Users/daylerees/www/panda/public/index.php(34): require('/Users/daylere\
25 e...')
26 #8 {main}This is the error that is shown if a requested view doesn’t exist at run time. As you can see
we have an informative error message from Laravel, as well as the file in which the error was
encountered, and a line number. In addition we also have a stacktrace that shows the initial
error, following all the method calls through the ‘View’ layer all the way down to the routing
Most of the time you won’t need the stacktrace, but it could prove useful for the more experienced
developers, for example when an error occurs within a complex library.



Skills    Laravel

Qualifications :-
Location :-,,,

  Students (0)