Search

Laravel Artisan Tinker: The dump Command

December 7, 2016 —John Koster

The dump command can be used to display information about a particular variable or class instance within the console window. It will display the information using Symfony's VarDumper console component:

1PHP Fatal error: Class 'User' not found in eval()'d code on line 1
2>>> $user = new App\User;
3=> App\User {#651}
4>>> dump $user
5App\User {#651}
6>>>

It also import to note that since the Tinker REPL is responding to commands within the context of a Laravel application, the dd helper function is also available, if its output proves useful:

1>>> dd($user)
2App\User {#651
3 #fillable: array:3 [
4 0 => "name"
5 1 => "email"
6 2 => "password"
7 ]
8 #hidden: array:2 [
9 0 => "password"
10 1 => "remember_token"
11 ]
12 #connection: null
13 #table: null
14 #primaryKey: "id"
15 #keyType: "int"
16 #perPage: 15
17 +incrementing: true
18 +timestamps: true
19 #attributes: []
20 #original: []
21 #relations: []
22 #visible: []
23 #appends: []
24 #guarded: array:1 [
25 0 => "*"
26 ]
27 #dates: []
28 #dateFormat: null
29 #casts: []
30 #touches: []
31 #observables: []
32 #with: []
33 #morphClass: null
34 +exists: false
35 +wasRecentlyCreated: false
36}

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.