December 7, 2016 —John Koster
The wtf
command is used to show details about the most recently thrown exception. When an exception is thrown, it is usually displayed in the console window with a red background stating that an exception has been thrown and the exception's message. The wtf
command will allow us to view the stack trace details for the exception; by default, it only shows a few lines of the exceptions stack trace.
There are two ways to view of an exception's stack trace using the wtf
command. To control the amount of information that is displayed, simply add varying amounts of question marks or exclamation points as the only arguments to the wtf
command. Issuing the wtf !??!!!!!
command would display more lines of the stack trace than simply issuing the wtf
command alone. Alternatively, the -v
option can be used to display the entire back trace.
The following example session throws an exception and uses the wtf
command to view the back trace (some lines have been manually wrapped and indented to improve readability):
1>>> throw new Exception("An example exception."); 2Exception with message 'An example exception.' 3>>> wtf !??! 4 5 6 [Exception] 7 An example exception. 8 910Exception trace:11 () at ...\vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php(79)12 : eval()'d code:113 eval() at ...\vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php:7914 Psy\ExecutionLoop\{closure}() at ...\vendor\psy\psysh\src\Psy\ExecutionLoop\15 Loop.php:13516 Psy\ExecutionLoop\Loop->run() at ...\vendor\psy\psysh\src\Psy\Shell.php:30717 Psy\Shell->doRun() at ...\vendor\symfony\console\Application.php:11718 Symfony\Component\Console\Application->run() at ...\vendor\psy\psysh\src\19 Psy\Shell.php:27320 Psy\Shell->run() at ...\vendor\laravel\framework\src\Illuminate\Foundation\21 Console\TinkerCommand.php:5422 Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a23 call_user_func_array() at ...\vendor\laravel\framework\src\Illuminate\24 Container\Container.php:50725 Illuminate\Container\Container->call() at ...\vendor\laravel\framework\src\26 Illuminate\Console\Command.php:16927 Illuminate\Console\Command->execute() at ...\vendor\symfony\console\28 Command\Command.php:25629 Symfony\Component\Console\Command\Command->run() at ...\vendor\laravel\30 framework\src\Illuminate\Console\Command.php:15531 Illuminate\Console\Command->run() at ...\vendor\symfony\console\32 Application.php:81533 Symfony\Component\Console\Application->doRunCommand() at ...\vendor\34 symfony\console\Application.php:18635 Symfony\Component\Console\Application->doRun() at ...\vendor\symfony\36 console\Application.php:11737 Symfony\Component\Console\Application->run() at ...\vendor\laravel\38 framework\src\Illuminate\Foundation\Console\Kernel.php:11139 Illuminate\Foundation\Console\Kernel->handle() at ...\artisan:364041--420: () at vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php(79)43 : eval()'d code:1441: eval() at vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php:79452: Psy\ExecutionLoop\{closure}() at vendor\psy\psysh\src\Psy\ExecutionLoop\46 Loop.php:135473: Psy\ExecutionLoop\Loop->run() at vendor\psy\psysh\src\Psy\Shell.php:307484: Psy\Shell->doRun() at vendor\symfony\console\Application.php:117495: Symfony\Component\Console\Application->run() at vendor\psy\psysh\src\Psy\50 Shell.php:273516: Psy\Shell->run() at vendor\laravel\framework\src\Illuminate\Foundation\52 Console\TinkerCommand.php:54537: Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a
∎