工匠:“找不到命令”

时间:2014-09-01 14:17:28

标签: laravel laravel-4

所以我尝试添加一个带

的命令
php artisan command:make MailSendCommand

创建了MailSendCommand.php文件。 我把它编辑成了这个:

class MailSendCommand extends Command {

    protected $name = 'command:send-mail';

    protected $description = 'Send mails to the users.';


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


    public function fire()
    {
        $this->info('Befehl wird ausgeführt' );
    }
...

在我的文件start / artisan.php中我添加了

Artisan::add(new MailSendCommand);

但是当我输入' php artisan命令时:send-mail'它说:

Command "command:send-mail" is not defined.

它只适用于我的家用电脑(XAMPP),但不适用于我的实时服务器(PHP 5.5.15(cgi-fcgi))

' php artisan clear:cache'和' php artisan dump-autoload'没有帮助。

2 个答案:

答案 0 :(得分:1)

看起来问题与您的设置有关。您正在使用PHP CGI而不是CLI来运行无法运行的命令。

确保您的实时环境中存在代码并在CLI上运行命令,因为这些是命令行脚本。

答案 1 :(得分:1)

转到app/Console/Kernel.php并将该类添加到commands变量中。它看起来像是:

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        Commands\MyCustomCommand::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
    }
}

这里我添加了MyCustomCommand作为有效的工匠命令。检查它是否正在执行的命令之中:

php artisan list
相关问题