【发布时间】:2021-05-06 09:21:13
【问题描述】:
我使用这个命令创建了一个工匠命令:
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 方法返回一个int。这是否意味着什么?如果我返回0 这意味着错误然后1 如果成功?我正在浏览 laravel 文档,它没有解释 handle 函数的返回值。
【问题讨论】: