问题
I have created a custom command using artisan:
php artisan make:command resetNegotiations
Than deleted cache with:
php artisan cache:clear
But if I try to run: php artisan ResetNegotiations I got the error:
Command "ResetNegotiations" is not defined.
The file ResetNegotiations.php exists in app/Console/Commands
I have found similar questions: - Command is not defined exception but it not fixed mine.
I have updated the kernel as https://laravel.com/docs/5.8/artisan#registering-commands in app/Console/Kernel.php but... nothing. The same error also after cache rebuilt.
kernel.php
....
protected $commands = [
Commands\ResetNegotiations::class,
//
];
What I'm missing?
This is the command:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class resetNegotiations extends Command{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';
/**
* 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 mixed
*/
public function handle()
{
//
mail("######@#####.it", "Scheduledartsan ", "Command test");
}
}
回答1:
protected $signature = 'command:name';
is what you use to call the command in artisan. just change the signature to protected $signature = 'resetNegotiations';
if you want to use that. The artisan command you posted should work after the change.
来源:https://stackoverflow.com/questions/58559912/laravel-5-8-custom-command-not-found