Closed hyncica closed 2 years ago
Interesting. Are there glob()
alternatives that work with PHAR as well?
I don't think there is any alternative that would work in same way as glob and would be able to deal with PHAR.
The glob()
function matches filenames in file system against given pattern. So, it's not (and won't be) able to work with streams. For glob()
the phar://
prefix is probably just part of pattern the function is looking for. The PHAR is an archive so it's present in filesystem only as the whole .phar
file.
If you want to look for files inside the PHAR archives you need to open the archive itself first. The only way to look for file in archive would be using opendir()
or scandir()
and going through the archive recursively. The Yiisoft\Files\FileHelper::findFiles()
might actually work because it uses opendir()
. But, I didn't test if the phar://
path can pass the is_dir()
test.
If you set file for config group using wildcards, no file will be loaded when the config folder is packed as part of PHAR archive. For example having common group defined as this will result in no config file loaded for it.
This is because glob() function used to resolve wildcards can't deal with PHAR archives.
This can be resolved by explicitly mentioning each config file, but it would be nice if there is some warning about that in documentation.