Laravel Artisan Tinker: The wtf Command

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
9
10Exception trace:
11 () at ...\vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php(79)
12 : eval()'d code:1
13 eval() at ...\vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php:79
14 Psy\ExecutionLoop\{closure}() at ...\vendor\psy\psysh\src\Psy\ExecutionLoop\
15 Loop.php:135
16 Psy\ExecutionLoop\Loop->run() at ...\vendor\psy\psysh\src\Psy\Shell.php:307
17 Psy\Shell->doRun() at ...\vendor\symfony\console\Application.php:117
18 Symfony\Component\Console\Application->run() at ...\vendor\psy\psysh\src\
19 Psy\Shell.php:273
20 Psy\Shell->run() at ...\vendor\laravel\framework\src\Illuminate\Foundation\
21 Console\TinkerCommand.php:54
22 Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a
23 call_user_func_array() at ...\vendor\laravel\framework\src\Illuminate\
24 Container\Container.php:507
25 Illuminate\Container\Container->call() at ...\vendor\laravel\framework\src\
26 Illuminate\Console\Command.php:169
27 Illuminate\Console\Command->execute() at ...\vendor\symfony\console\
28 Command\Command.php:256
29 Symfony\Component\Console\Command\Command->run() at ...\vendor\laravel\
30 framework\src\Illuminate\Console\Command.php:155
31 Illuminate\Console\Command->run() at ...\vendor\symfony\console\
32 Application.php:815
33 Symfony\Component\Console\Application->doRunCommand() at ...\vendor\
34 symfony\console\Application.php:186
35 Symfony\Component\Console\Application->doRun() at ...\vendor\symfony\
36 console\Application.php:117
37 Symfony\Component\Console\Application->run() at ...\vendor\laravel\
38 framework\src\Illuminate\Foundation\Console\Kernel.php:111
39 Illuminate\Foundation\Console\Kernel->handle() at ...\artisan:36
40
41--
420: () at vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php(79)
43 : eval()'d code:1
441: eval() at vendor\psy\psysh\src\Psy\ExecutionLoop\Loop.php:79
452: Psy\ExecutionLoop\{closure}() at vendor\psy\psysh\src\Psy\ExecutionLoop\
46 Loop.php:135
473: Psy\ExecutionLoop\Loop->run() at vendor\psy\psysh\src\Psy\Shell.php:307
484: Psy\Shell->doRun() at vendor\symfony\console\Application.php:117
495: Symfony\Component\Console\Application->run() at vendor\psy\psysh\src\Psy\
50 Shell.php:273
516: Psy\Shell->run() at vendor\laravel\framework\src\Illuminate\Foundation\
52 Console\TinkerCommand.php:54
537: Illuminate\Foundation\Console\TinkerCommand->fire() at n/a:n/a

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.