简体   繁体   中英

Laravel 5.8 custom command not found

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");

}

}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM