Skip to content

Instantly share code, notes, and snippets.

@CarsonF
Last active September 30, 2015 18:41
Show Gist options
  • Save CarsonF/ac8d49b799b2e4cca1cc to your computer and use it in GitHub Desktop.
Save CarsonF/ac8d49b799b2e4cca1cc to your computer and use it in GitHub Desktop.
Using Symfony's Finder with our Filesystem abstraction...
<?php
use Bolt\Filesystem\Filesystem;
use Bolt\Filesystem\Local;
$fs = new Filesystem(new Local(__DIR__));
foreach ($fs->find()->files() as $file) {
/** @var \Bolt\Filesystem\File $file */
echo $file->getFilename() . '\n';
}
foreach ($fs->find()->directories() as $directory) {
/** @var \Bolt\Filesystem\Directory $directory */
echo $directory->getPath();
}
/** @var \Symfony\Component\Finder\Finder $finder */
$finder = $fs->find();
$iterator = $finder
->files()
->name('*.php')
->depth(0)
->size('>= 1K');
$beers = $fs->find()
->files()
->in('beers')
->size('> 375ml');
@bobdenotter
Copy link

🍺 🍻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment