回调前的Laravel 5.1不起作用


Laravel 5.1 before callback is not working

在Laravel 5.1中的任务调度程序中,回调不起作用:

protected function schedule(Schedule $schedule)
{
    $schedule->command('inspire')->hourly();
    $schedule->command('view:clear')->daily();
    $schedule->call(function(){
        ToolsController::fixCategory();
        })
        ->everyMinute()
        ->before(function () {
            // Task is about to start...
            Log::info('Start fixing Category');
        })
        ->after(function () {
            // Task is complete...
            Log::info('End fixing Category');
        });
}

在日志文件中:

[2015-12-04 12:02:22] local.INFO: End fixing Category  
[2015-12-04 12:06:08] local.INFO: End fixing Category  

知道吗?

感谢@Svetlio

命令类:

class FixCategory extends Command
{
/**
 * The name and signature of the console command.
 *
 * @var string
 */
protected $signature = 'FixCategory';
/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Fix Category';
/**
 * Execute the console command.
 *
 * @return mixed
 */
public function handle()
{
    ToolsController::fixCategory();
}
}

内核类:

class Kernel extends ConsoleKernel
{
/**
 * The Artisan commands provided by your application.
 *
 * @var array
 */
protected $commands = [
    'App'Console'Commands'Inspire::class,
    'App'Console'Commands'FixCategory::class,
];
/**
 * Define the application's command schedule.
 *
 * @param  'Illuminate'Console'Scheduling'Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('inspire')->hourly();
    $schedule->command('view:clear')->daily();
    $schedule->command('FixCategory')
        ->everyMinute()
        ->before(function () {
            // Task is about to start...
            Log::info('Start fixing Category');
        })
        ->after(function () {
            // Task is complete...
            Log::info('End fixCategory');
        });
}
}

日志文件:

[2015-12-04 12:44:49] local.INFO: Start fixing Category  
[2015-12-04 12:44:50] local.INFO: End fixing Category