【问题标题】:Laravel 4 custom commands not being found未找到 Laravel 4 自定义命令
【发布时间】:2015-05-29 06:27:56
【问题描述】:

我正在尝试使用 php artisan 在 Laravel 中创建一个自定义命令,但尽管我完成了这里写的所有内容:http://laravel.com/docs/4.2/commands,包括命令的注册,但当我键入时它仍然没有在命令列表中列出php工匠。

这是命令:

<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;

class PremiumSets extends Command {
    protected $name = 'sets:check';
    protected $description = 'Check if any of the users did not select a premium set.';

    public function __construct()
    {
        parent::__construct();
    }

    public function fire()
    {
        Log::error("PremiumSets Here");
    }

    protected function getArguments()
    {
        return [];
    }

    protected function getOptions()
    {
        return [];
    }
}
?>

\app\start\artisan.php(我也试过使用 Artisan::resolve(),但还是不行)

<?php

/*
|--------------------------------------------------------------------------
| Register The Artisan Commands
|--------------------------------------------------------------------------
|
| Each available Artisan command must be registered with the console so
| that it is available to be called. We'll register every command so
| the console gets access to each of the command object instances.
|
*/

Artisan::add(new PremiumSets);

【问题讨论】:

  • 你试过运行composer dump吗?
  • 你的命令的文件位置和文件名是什么?
  • 我尝试了作曲家转储,仍然没有运气。位置是\app\commands\PremiumSets.php

标签: laravel laravel-4 command laravel-artisan


【解决方案1】:

尝试在您的 \app\start\artisan.php 中写入完整路径,例如:

Artisan::add(new App\Commands\PremiumSets);

【讨论】:

    【解决方案2】:

    找到解决方案!确保您的 routes.php 中没有此代码:

    工匠::call('up');

    【讨论】:

      猜你喜欢
      • 2020-02-21
      • 1970-01-01
      • 2015-04-06
      • 2018-02-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-10
      相关资源
      最近更新 更多