December 7, 2016 —John Koster
The doc
command can be used to view the documentation for an object, class, constant, method, function or property. It can accept either the function, method, class, etc name or a reference to an instance's methods as its arguments. Because of Laravel's numerous and high quality code documentation, this command is very useful.
For example, we can look at the documentation for the config
helper function within the command-line environment (some lines have been manually wrapped and indented to prevent wrapping that may cause readability issues):
1>>> doc config 2function config($key = null, $default = null) 3 4Description: 5 Get / set the specified configuration value. 6 7 If an array is passed as the key, we will assume you want to set an 8 array of values. 910Param:11 array|string $key12 mixed $default1314Return:15 mixed16>>> doc auth17function auth($guard = null)1819Description:20 Get the available auth instance.2122Param:23 string|null $guard2425Return:26 \Illuminate\Contracts\Auth\Factory|\Illuminate\Contracts\Auth\27 Guard|\Illuminate\Contracts\Auth\StatefulGuard
To contrast, the following example demonstrates how to retrieve the documentation for a class property; in this case, the doc
command is being used to display the help information related to the $table
property on an Eloquent model:
1>>> $user = new App\User2=> App\User {#644}3>>> doc $user->table4protected $table56Description:7 The table associated with the model.89Var: string
∎
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.