0
我有以下代碼來查找我的源代碼樹中名爲robofile-templates的目錄中的文件。 現在我將應用程序打包到phar文件中。使用symfony查找程序在phar中查找文件
我可以使用相似的代碼來遍歷phar文件中包含的文件,還是我必須重寫它?
protected function getTemplateRoboFiles() {
$base = dirname(__DIR__);
$templates = [];
$finder = new Finder();
$finder->directories()->in($base)->name('robofile-templates');
foreach ($finder as $directory) {
$fileFinder = new Finder();
$fileFinder->files()->in($directory->getRealPath())->name('*.php');
foreach ($fileFinder as $file) {
$templates[ $file->getBasename('.php') ] = $file->getRealPath();
}
}
return $templates;
}
編輯:夠有意思,裏面藥業opendir
/readdir
工作。我可以訴諸使用這些基本的文件功能,但我認爲Symfony文件查找程序是基於相同的基本命令構建的?