Search code examples
phplaravellaravel-artisan

Getting a List of Artisan Commands Programmatically


When you're using the Laravel PHP Framework, is there a way, (at runtime), to programmatically fetch a list of currently configured and available artisan commands? I'm basically looking for way to know

  1. All the command names

  2. The class or objects that corresponds to that class


Solution

  • As usual, self help desk strikes as soon as I ask myself the question clearly.

    //app()->make('artisan')->all();        
    foreach(Artisan::all() as $key=>$command)
    {
        var_dump($key);
        var_dump(get_class($command));
    }