假设一个文件结构:
config
└── folder
└── subfolder
我想使用仅使用symfony finder组件的内容文件夹的查找器组件来迭代文件,而不是使用任何子文件夹。
目前,我发现排除子文件夹的唯一方法是硬编码:
foreach($fileFinder->in($portalConfigPath)->files()->exclude('subfolder') as $file) {...}
如何排除将来可能添加的任何新子文件夹?我尝试'*'
作为通配符,但它在这里不起作用。
您可以将深度设置为 0 以不遍历到子文件夹:
foreach ($fileFinder->in($portalConfigPath)->files()->depth('== 0') as $file) {...}