Laravel 5.8 custom command not found

别说谁变了你拦得住时间么 提交于 2020-12-15 11:47:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!