<?php class resqueTest { public function actionWork() { #require dirname(__DIR__).'/commands/TestJob.php'; $this->requireAllJob(); require dirname(__DIR__).'/vendor/chrisboulton/php- resque/resque.php'; } /** *遍历Job目录取出所有的Job类 */ private function requireAllJob() { #job path SPL DirectoryIterator迭代器 foreach (new DirectoryIterator(dirname(__DIR__).'/job') as $fileInfo) { #如果不是文件跳过 if ($fileInfo->isDot() || $fileInfo->isDir()) { continue; } require $fileInfo->getPath().'/'.$fileInfo->getFilename(); } } }