This is concerning Laravel 5.
I can see in Illuminate\Filesystem\Filesystem
a method called glob($pattern, $flags = 0)
Unfortunately, this method is not reflected in the default FilesystemAdapter
shipped with Laravel 5.
This would be great, due to the fact that I would need to do something like Storage::disk('local')->glob([_]*[.blade.php]);
(in order to get all stored blade files starting with an underscore.
What is the cleanest way to achieve this?
I think you cannot run glob
here, but you could get all files and then filter them, for example:
$files = array_filter(Storage::disk('local')->files(), function ($file)
{
return preg_match('/_(.*)\.blade\.php$/U', $file);
});
Of course you need to decide to use files
or allFiles
(recursively) depending on your needs. Probably it's not the best solution if you have thousands of files but if you don't it should be enough
来源:https://stackoverflow.com/questions/29729863/how-to-leverage-the-glob-method-of-filesystem-class-with-storagefacade