<?php
namespace process;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
new Crontab('* * * * * *', $this->abc());
}
public function abc() {
return function() {
echo "callback\n";
};
}
}
<?php
namespace process;
use Workerman\Crontab\Crontab;
class Task
{
public function onWorkerStart()
{
new Crontab('* * * * * *', [$this, 'abc']);
}
public function abc() {
return function() {
echo "callback\n";
};
}
}
https://github.com/walkor/crontab/blob/b78f1556f2977715b9cb5653129e6d9cf160d966/src/Crontab.php#L54
Crontab的构造函数第二个参数接受的是一个callback,所以你的姿势不对,应该这样
👍赞
正确姿势应该是
👍赞
mark