Laravel Artisan Tinker: The show Command

December 7, 2016 —John Koster

The show command is similar to the ls command in that it helps you to learn more about a class instance or object, except that it will show you the underlying code for any function, class, object instance, constant, method or property. Using our $user Eloquent model from the ls section, we can easily view the code behind the model's can method:

1>>> show $user::can
2 > 16| public function can($ability, $arguments = [])
3 17| {
4 18| return app(Gate::class)->forUser($this)->check($ability,
5 $arguments);
6 19| }

The show command can also be used to view the code behind functions defined in the global namespace, such as the dd helper function:

1>>> show dd
2 > 492| function dd()
3 493| {
4 494| array_map(function ($x) {
5 495| (new Dumper)->dump($x);
6 496| }, func_get_args());
7 497|
8 498| die(1);
9 499| }

It can also be used to show entire class definitions, such as when issuing the show App\User command to view the code behind the default User Eloquent model.

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.