Last active
September 30, 2015 18:41
-
-
Save CarsonF/ac8d49b799b2e4cca1cc to your computer and use it in GitHub Desktop.
Using Symfony's Finder with our Filesystem abstraction...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
🍺 🍻