While it is simple to create custom Artisan commands there are other times where it may be necessary to customize the core console application further. The Artisan console application (Illuminate\Console\Application) extends Symfony's console application (Symfony\Component\Console\Application); this means that the same modifications that can be made to Symfony's console application should also apply to the Artisan console application. Such modifications include changing the default command, application name and application versions string.

Since we know that Laravel's console application extends Symfony's, we need to discover where exactly this is being brought in and invoked. Looking at the App\Console\Kernel (the kernel that is available to "user-land" code for registering commands and scheduling commands) we can see that it extends a framework console kernel located at Illuminate\Foundation\Console\Kernel. Performing a quick string search within the Kernel file for Illuminate\Console\Application reveals that an instance of the console application is set and returned by the getArtisan protected method. Since the method is marked as protected any inherited classes can call or override the method if they want (see the Visibility section in the PHP manual for more information related to method visibility).

It is by overriding this method that we are able to make customizations to the actual console application instance. However, we need to make sure that our modified version of getArtisan sets the $artisan instance property as well as returns the application instance.

Here is what a Kernel class might look like with the modified getArtisan method:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        // Commands\Inspire::class,
        Commands\TestCommand::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
    }

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        // $this->command('build {project}', function ($project) {
        //     $this->info('Building project...');
        // });
    }

    protected function getArtisan()
    {
        // Check if the artisan property is null; If so
        // we need to instantiate it by calling the
        // getArtisan method on the base class;
        // after this we can make any of the
        // modifications we want before we
        // return the app instance back.
        if (is_null($this->artisan)) {
            $this->artisan = parent::getArtisan();

            // Make our modifications here.

            // Rename the console application.
            $this->artisan->setName('Laravel Artisan');

            // Change the version number.
            $this->artisan->setVersion('1.0.0');

        }

        return $this->artisan;
    }

}

Now, when a user invokes php artisan in the shell they would see the following output (take note of the application name and version number on the first line):

Laravel Artisan version 1.0.0

Usage:
  command [options] [arguments]

...

It is also possible to easily modify the default command that is executed when the artisan console application is invoked without specifying a command. By default the list command is executed and will list all of the registered commands. However, this can be changed within our modified getArtisan method:

<?php

// ...

function getArtisan()
{
    if (is_null($this->artisan)) {
        $this->artisan = parent::getArtisan();

        // Change the default command.
        $this->artisan->setDefaultCommand('route:list');
    }

    return $this->artisan;
}

// ...

With the above modification when a user types php artisan in their shell and hits the enter key on a fresh Laravel installation they would see the following routes table instead of the command listing:

+--------+----------+-----+------+---------+------------+
| Domain | Method   | URI | Name | Action  | Middleware |
+--------+----------+-----+------+---------+------------+
|        | GET|HEAD | /   |      | Closure | web        |
+--------+----------+-----+------+---------+------------+

These modifications can be useful when developing for clients that require custom branding throughout all areas of an application.