2016-05-02 58 views
-1

我正在使用laravel 4,我想使用我在https://laravel.com/docs/master/scheduling#introduction找到的任务计划,但由于某些原因,它不起作用。Laravel 4任务计划不能正常工作

[email protected] c:\xampp\htdocs\ski\theskitrip\protected 
# php artisan schedule:run 



    [InvalidArgumentException] 
    There are no commands defined in the "schedule" namespace. 




[email protected] c:\xampp\htdocs\ski\theskitrip\protected 

我只是想知道,因为我按照文档中,我创建了.../app/Console/Kernel.php这也是Kernel.php

<?php 

namespace App\Console; 

use DB; 
use Illuminate\Console\Scheduling\Schedule; 
use Illuminate\Foundation\Console\Kernel as ConsoleKernel; 

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

    /** 
    * Define the application's command schedule. 
    * 
    * @param \Illuminate\Console\Scheduling\Schedule $schedule 
    * @return void 
    */ 
    protected function schedule(Schedule $schedule) 
    { 
     $schedule->call(function() { 
      DB::table('tb_applicants')->insert(array('fullname' => "Mar Binay", 'email' => "[email protected]")); 
     })->everyMinute(); 
    } 
} 

内容没有任何人对我的情况下的想法?我不想使用cron,因为它非常棘手。

问题,是否需要创建类似于这个PHP工匠的时间表? https://laravel.com/docs/master/artisan

+0

这些错误看起来与您的计划任务没有任何关联。它们是HTTP请求错误。你是否与工匠一起完成计划? – Devon

+0

我对此感到困惑。我将修改我的问题 – gadss

+0

Laravel 4没有'schedule:run'命令。在提到文档时,请确保您选择4.2而不是主人。师父指的是最新版本。 – Devon

回答

2

任务调度可以从Laravel 5中获得,所以如果你正在编写你使用的是Laravel 4 - 它根本不会工作!

.../app/Console/Kernel.php - LAravel 4目前还不支援这个档案。