簡體   English   中英

Laravel 5.8 自定義命令未找到

[英]Laravel 5.8 custom command not found

我使用工匠創建了一個自定義命令:

php 工匠制作:命令重置談判

比刪除緩存:

php 工匠緩存:清除

但是,如果我嘗試運行: php artisan ResetNegotiations我得到了錯誤:

命令“ResetNegotiations”未定義。

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

我發現了類似的問題: - 命令未定義異常,但未修復我的。

我已在 app/Console/Kernel.ZE1BFD762321E409CEE4AC0B6E8 中將 kernel 更新為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");

}

}

protected $signature = 'command:name'; 是你用來在工匠中調用命令的東西。 只需將簽名更改為protected $signature = 'resetNegotiations'; 如果你想使用它。 您發布的工匠命令應該在更改后工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM