Laravel 5 - Creating Artisan Command for Packages

I have been following along and able to create artisan command in Laravel 5. But, how can I create artisan command and package it to packages?


ANSWERS:


You can and should register the package commands inside a service provider using $this->commands() in the register() method:

namespace Vendor\Package;

class MyServiceProvider extends ServiceProvider {

    protected $commands = [
        'Vendor\Package\Commands\MyCommand',
        'Vendor\Package\Commands\FooCommand',
        'Vendor\Package\Commands\BarCommand',
    ];

    public function register(){
        $this->commands($this->commands);
    }
}


 MORE:


 ? Laravel 5 - Creating Artisan Command for Packages
 ? Laravel 5 - Creating Artisan Command for Packages
 ? Create artisan commands for package Laravel 5
 ? How to call Model via artisan command in Laravel 5?
 ? Laravel 5 php artisan not running in Vagrant, missing vendor/services.json?
 ? Laravel 5 php artisan not running in Vagrant, missing vendor/services.json?
 ? Laravel 5 php artisan not running in Vagrant, missing vendor/services.json?
 ? How to use composer, artisan ...(Laravel) php commands manually
 ? Laravel artisan exception details
 ? PhpStorm Laravel artisan Mamp