加载指定文件夹文件并执行静态方法
private static function initEvents()
{
        //扫描文件夹下的所有文件
        $files = scandir(__DIR__ . '/EventHandlers');
        foreach($files as $file)
        {
            if($file != '.' && $file != '..')
            {
                include_once(__DIR__ . '/EventHandlers/' . $file);
                //调用文件的静态方法
                call_user_func(pathinfo($file, PATHINFO_FILENAME) . '::onWorkerStart');
            }
        }

}

首页 我的博客
粤ICP备17103704号