use*_*781 17 php laravel laravel-5 artisan
我一直关注http://laravel.com/docs/5.0/commands并能够在Laravel 5中创建artisan命令.但是,我如何创建artisan命令并将其打包到包中?
luk*_*ter 41
您可以并且应该$this->commands()在register()方法中使用以下方法在服务提供者中注册包命令:
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);
}
}
Run Code Online (Sandbox Code Playgroud)