$slackNotify = function() use (&$info) { ... };
$schedule->command('Calc:RPI 1 2015')->cron('0 */2 * 8-12 *')
->withoutOverlapping()->sendOutputTo($this->path . 'rpi.html')
->after($slackNotify('My message here'));
错误:参数1传递给Illuminate'Console'Scheduling'Event::after()必须是Closure, string given,…的实例
为什么它认为$slackNotify(...)
是字符串?
原来我使用的是lambda而不是匿名函数(几乎是相同的东西,但仍然不是)。
->after()
命令需要一个匿名函数,所以我只需要添加它并将lambda传递给它:
WAS/Lambda:
->after($slackNotify('My Message Here'));
IS/anonymous:
->after(function() use ($slackNotify) {$slackNotify('My Message Here');});
感谢rizqi帮我解释我到底在做什么