Add Useful Info to the Laravel About Command

Published on : July 27,2022
Add Useful Info to the Laravel About Command

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!

Categories : Laravel PHP

Tags : PHP Laravel

Praful Sangani
Praful Sangani
I'm a passionate full-stack developer with expertise in PHP, Laravel, Angular, React Js, Vue, Node, Javascript, JQuery, Codeigniter, and Bootstrap. I enjoy sharing my knowledge by writing tutorials and providing tips to others in the industry. I prioritize consistency and hard work, and I always aim to improve my skills to keep up with the latest advancements. As the owner of Open Code Solution, I'm committed to providing high-quality services to help clients achieve their business goals.


25 Comments

tricor uk order tricor 160mg without prescription cheap fenofibrate 200mg


order generic cialis 10mg 50mg viagra buy generic sildenafil 100mg


order generic acarbose 50mg buy micronase without prescription griseofulvin order online


minoxidil medication buy tadalafil 10mg without prescription best ed pills non prescription


buy aspirin no prescription hydroquinone where to buy cost imiquimod


dipyridamole 25mg over the counter buy lopid without a prescription pravachol drug


florinef order buy dulcolax 5 mg sale buy generic imodium over the counter


purchase prasugrel sale detrol sale tolterodine pills


buy monograph pills oral colospa 135 mg buy pletal online


buy ferrous sulfate 100 mg for sale order betapace 40 mg for sale order sotalol sale


where to buy betahistine without a prescription haloperidol 10 mg us order probalan without prescription


xalatan cheap buy latanoprost no prescription oral exelon 3mg


prilosec canada buy singulair 5mg pills metoprolol 50mg without prescription


buy premarin pills for sale cheap sildenafil for sale order sildenafil 100mg without prescription


telmisartan 20mg generic purchase molnunat online order molnunat sale


cenforce 50mg oral cenforce without prescription purchase chloroquine without prescription


order cialis 10mg for sale oral cialis 20mg viagra 50mg over the counter


cefdinir pills purchase omnicef for sale generic prevacid


buy modafinil 200mg generic order promethazine online prednisone 20mg without prescription


order isotretinoin sale buy generic amoxicillin for sale azithromycin canada


brand atorvastatin 20mg oral atorvastatin 10mg cost norvasc


purchase azipro buy azithromycin pill neurontin 100mg price


buy pantoprazole generic phenazopyridine 200 mg drug pyridium over the counter


best online casino games best poker online real money lasix generic


real money spins online sugarhouse casino online albuterol canada


Leave a comment

We'll never share your email with anyone else. Required fields are marked *

Related Articles

Access specifier in php
Praful Sangani By Praful Sangani - July 20,2022