Assume a file structure:
config
└── folder
└── subfolder
I want to iterate over the files using the finder component of only the content folder using the symfony finder component but not any subfolder.
Currently, the only way I found to exclude the subfolder is a hardcoded:
foreach($fileFinder->in($portalConfigPath)->files()->exclude('subfolder') as $file) {...}
How to exclude any new subfolder that may be added in the future? I tried '*'
as a wildcard, yet it doesn't work here.
You can set the depth to 0 to not traverse to subfolders:
foreach ($fileFinder->in($portalConfigPath)->files()->depth('== 0') as $file) {...}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With