wgirhad / filename-iterator
Glob-like recursive file iterator
v1.0.0
2023-04-09 02:24 UTC
Requires
- php: ^8.1
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: ^3.7
README
Glob-like recursive file iterator
Usage Examples
Given the following file structure:
src/CoolestClass.php
src/SecondCoolest.php
tests/CoolestClassTest.php
tests/SecondCoolestTest.php
public/static/foo.png
public/static/bar.gif
public/static/images/bar.png
public/static/images/baz.png
public/static/images/fizz.jpeg
public/static/images/buzz.jpg
public/static/images/.peek/aboo.png
Listing all .png
images on public/static
<?php use Wgirhad\FilenameIterator\Iterator as FilenameIterator; foreach (new FilenameIterator('public/static', '*.png') as $filename) { echo "{$filename}\n"; } // outputs: // public/static/foo.png // public/static/images/bar.png // public/static/images/baz.png // public/static/images/.peek/aboo.png
Listing all Coolest
files
<?php use Wgirhad\FilenameIterator\Iterator as FilenameIterator; foreach (new FilenameIterator('*', '*Coolest*.php') as $filename) { echo "{$filename}\n"; } // outputs: // src/CoolestClass.php // src/SecondCoolest.php // tests/CoolestClassTest.php // tests/SecondCoolestTest.php