• Reading time ~ 2 min
  • 10.08.2022

The Laravel about command released in Laravel 9.21 provides an excellent overview of important configurations for your application. Out of the box, it lists environment details, cache status, and configured drivers:

Another neat feature of the new about command is the ability for packages to add helpful information too. For example, we've covered Filament components here on Laravel News; after the release of Laravel 9.21, Ryan Chandler opened a pull request to add useful plugin details to Filament.

I think we'll see a lot of package authors add helpful details to the about command. Hopefully, the end-user doesn't get overwhelmed with too much info, or perhaps package developers make the inclusion of data in the about command configurable.

With that intro out of the way, how would you add custom data to the about command?

You can do so in a service provider, using the AboutCommand::add() method within the service provider's boot() method.

In the following example, let's say I wanted my package or application to output specific XDebug configuration values:

use Illuminate\Foundation\Console\AboutCommand;
 
// ...
 
public function boot()
{
    AboutCommand::add('XDebug Settings', [
        'Client Port' => fn() => ini_get('xdebug.client_port'),
        'Client Host' => fn() => ini_get('xdebug.client_host'),
        'Start With Request' => fn() => ini_get('xdebug.start_with_request'),
        'Max Nesting Level' => fn() => ini_get('xdebug.max_nesting_level'),
        'Mode' => fn() => ini_get('xdebug.mode'),
        'Output Dir' => fn() => ini_get('xdebug.output_dir'),
        'Log' => fn() => !empty(ini_get('xdebug.log')) ? ini_get('xdebug.log') : 'No Value',
    ]);
}

The above might look like the following locally, depending on your XDebug configuration:

Lazy Loading

One thing to note when creating custom about commands is that you should lazy load the output by wrapping the settings in an fn() => arrow function. For example:

1'Client Port' => ini_get('xdebug.client_port'), 2'Client Port' => fn() => ini_get('xdebug.client_port'),

I am excited to see what helpful information package authors start adding to this command!

Comments

No comments yet
Yurij Finiv

Yurij Finiv

Full stack

ABOUT

Professional Fullstack Developer with extensive experience in website and desktop application development. Proficient in a wide range of tools and technologies, including Bootstrap, Tailwind, HTML5, CSS3, PUG, JavaScript, Alpine.js, jQuery, PHP, MODX, and Node.js. Skilled in website development using Symfony, MODX, and Laravel. Experience: Contributed to the development and translation of MODX3 i...

About author CrazyBoy49z
WORK EXPERIENCE
Contact
Ukraine, Lutsk
+380979856297