我使用以下命令创建了一个工匠命令:
php artisan make:command --command=custom:command SomeCustomCommand
运行命令后,它创建了以下文件:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class SomeCustomCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'custom:command';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
return 0;
}
}
我发现默认情况下,
handle
方法返回一个整数。这是有意义的吗?如果我返回0
表示错误,那么返回1
表示成功吗?我正在查看Laravel文档,但没有说明handle
函数应该返回什么。