내 Laravel 5.2 응용 프로그램의 일부로 숙련 된 사용자 지정 명령을 정의하고 싶지만 내 명령은 artisan list
에 표시되지 않습니다.Laravel5 콘솔 등록하지 않음
1). 커맨드 뼈대를 만들었습니다 : artisan make:console --command=process:emails
2). 나는 새 클래스의 handle()
방법으로 테스트 코드의 비트를 추가 :
<?php
namespace App\Console\Commands;
use App\CommunicationsQueue;
use Illuminate\Console\Command;
class ProcessEmailQueueCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'process:email';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Send all currently pending emails in the queue';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
CommunicationsQueue::where('status', 'PENDING')->update(['status'=>'TEST']);
$this->info('The mails queue was successfully processed.');
}
}
3). 그런 다음, 나는 app/Console/Kernel.php
에 명령을 등록했다 :
protected $commands = [
'App\Console\Commands\ProcessEmailQueueCommand',
];
나는 무엇을 여기에서 놓치고 있냐? 믿을 수 없을만큼 단순한 것이 겠지만, 나는 그것을 보지 않을 것입니다. app/Console/Kernel.php
에서
그냥 한 눈에 ... 그 모습을 당신의 해당 명령을 제대로 등록하지 않았습니다. App \ Commands가 없으면 전체 네임 스페이스를 입력하지 않은 것입니다. – jhmilan