我试图在laravel 5.0中创建我自己的命令,但是会产生以下错误。我已经在内核中注册了我的命令。以下是我的代码 //跟随错误
[ErrorException]
Argument 1 passed to Illuminate\Console\Application::add() must be an instance of Symfony\Component\Console\Command
\Command, instance of App\console\Commands\qwork given, called in C:\xampp\htdocs\queue_mail\vendor\laravel\framewo
rk\src\Illuminate\Console\Application.php on line 115 and defined
//我的命令qwork.php
<?php namespace App\console\Commands;
use DB;
use App\Commands\Command;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldBeQueued;
class qwork extends Command implements SelfHandling, ShouldBeQueued {
use InteractsWithQueue, SerializesModels;
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
DB::insert('insert into users (name, email) values (?, ?)', ['faran', 'ran.rana@gmail.com']);
}
}
//then defining route by:
Route::get('/run', function()
{
Artisan::queue('command:qwork');
});
答案 0 :(得分:0)
替换
use App\Commands\Command;
与
use Illuminate\Console\Command;