假设一个文件结构:
config
└── folder
└── subfolder
我想使用 finder component 遍历文件仅使用 symfony 查找器组件的内容文件夹,而不是任何子文件夹。
目前,我发现排除子文件夹的唯一方法是硬编码:
foreach($fileFinder->in($portalConfigPath)->files()->exclude('subfolder') as $file) {...}
如何排除将来可能添加的任何新子文件夹?我尝试将 '*'
作为通配符,但它在这里不起作用。
最佳答案
您可以设置 depth to 0不遍历子文件夹:
foreach ($fileFinder->in($portalConfigPath)->files()->depth('== 0') as $file) {...}
关于php - 如何忽略查找器组件中的任何子文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35367510/