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
You can do so in a service provider, using the
AboutCommand::add() method within the service provider’s
In the following example, let’s say I wanted my package or application to output specific XDebug configuration values:
5public function boot()
7 AboutCommand::add('XDebug Settings', [
8 'Client Port' => fn() => ini_get('xdebug.client_port'),
9 'Client Host' => fn() => ini_get('xdebug.client_host'),
10 'Start With Request' => fn() => ini_get('xdebug.start_with_request'),
11 'Max Nesting Level' => fn() => ini_get('xdebug.max_nesting_level'),
12 'Mode' => fn() => ini_get('xdebug.mode'),
13 'Output Dir' => fn() => ini_get('xdebug.output_dir'),
14 '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:
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!
Credit: Source link