简体   繁体   English

Laravel 5.8 自定义命令未找到

[英]Laravel 5.8 custom command not found

I have created a custom command using artisan:我使用工匠创建了一个自定义命令:

php artisan make:command resetNegotiations php 工匠制作:命令重置谈判

Than deleted cache with:比删除缓存:

php artisan cache:clear php 工匠缓存:清除

But if I try to run: php artisan ResetNegotiations I got the error:但是,如果我尝试运行: php artisan ResetNegotiations我得到了错误:

Command "ResetNegotiations" is not defined.命令“ResetNegotiations”未定义。

The file ResetNegotiations.php exists in app/Console/Commands文件ResetNegotiations.php存在于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.我已在 app/Console/Kernel.ZE1BFD762321E409CEE4AC0B6E8 中将 kernel 更新为https://laravel.com/docs/5.8/artisan#registering-commands The same error also after cache rebuilt.缓存重建后也出现同样的错误。

kernel.php 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';只需将签名更改为protected $signature = 'resetNegotiations'; if you want to use that.如果你想使用它。 The artisan command you posted should work after the change.您发布的工匠命令应该在更改后工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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