找不到Laravel 5.8自定义命令

问题描述 投票:0回答:1

我已经使用工匠创建了自定义命令:

php artisan make:command resetNegotiations

比使用以下方法删除缓存:

php artisan cache:clear

但是如果我尝试运行:php artisan ResetNegotiations我得到了错误:

未定义命令“ ResetNegotiations”。

文件ResetNegotiations.php存在于app / Console / Commands

我发现了类似的问题:-Command is not defined exception,但不是固定的。

我已经在app / Console / Kernel.php中将内核更新为https://laravel.com/docs/5.8/artisan#registering-commands,但是……什么也没有。重建缓存后,也会出现相同的错误。

kernel.php

 ....
 protected $commands = [
    Commands\ResetNegotiations::class,
    //
];

我想念的是什么?

这是命令:

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

}

}

php laravel laravel-5.8 artisan
1个回答
0
投票
protected $signature = 'command:name';是您在工匠中用来调用命令的内容。如果要使用,只需将签名更改为protected $signature = 'resetNegotiations';。您发布的工匠命令应在更改后起作用。
© www.soinside.com 2019 - 2024. All rights reserved.