symfony/finder
Symfony Finder component provides a fluent API to locate and iterate files and directories. Filter by name, extension, size, date, contents, or path; search multiple locations; and traverse recursively with sorting and ignore rules for flexible filesystem searches.
Build vs. Buy Decision:
Illuminate\Filesystem\Filesystem), making it a zero-cost upgrade for existing Laravel projects.Feature Roadmap Enablement:
storage:optimize command to find and compress large files in /storage/app.tests/Fixtures/**/*.json) or generating test datasets based on file patterns..md files modified in the last 30 days")..php files in /app and verify their checksums").Use Cases:
Storage facade, Filesystem manager, and Console component, reducing friction for developers.glob() calls in custom packages or service providers with Finder for consistency and reliability./public for assets or /storage for logs).minSize(), maxSize()), extension (name('*.png')), modification date (date('>1 month ago')), or permissions (permissible()).Architectural Alignment:
Console, Process), which Laravel already leverages, reducing learning curves and tooling overhead.Adopt when:
glob()/scandir() calls, DirectoryIterator logic, or regex-based file matching.config:clear, cache:clear, and route:clear./storage or /public) where memory efficiency matters.Look elsewhere if:
glob() calls for fewer than 100 files). For simple cases, native glob() or scandir() may suffice.symfony/finder:6.4.x for PHP 7.4+ or 5.4.x for PHP 5.5+.ReactPHP or Symfony/Process for async workflows.Storage facade or cloud SDKs instead.SplFileInfo, RecursiveDirectoryIterator, or Iterator).FtpManager or SftpManager alongside Finder for hybrid workflows.league/flysystem, spatie/laravel-medialibrary) that already include file-search capabilities.To Executives: *"Symfony’s Finder is a pre-built, production-grade toolkit for filesystem operations—like a Swiss Army knife for file searches. It replaces error-prone custom scripts with a reliable, maintainable API, cutting development time and reducing bugs. Here’s why it’s a smart investment:
/storage for 10,000+ files without memory issues), critical for growth.To Engineers:
*"This replaces messy glob()/DirectoryIterator hacks with a type-safe, expressive API. Key wins:
Finder::in('/path')->name('*.php')->size('>1M')->files() is self-documenting and easier to debug than nested if statements or regex.Storage, Filesystem, and Artisan commands—no context-switching. Example: Replace glob() in custom packages with Finder for consistency.Finder instances for mocking in unit tests (e.g., with VfsStream or Mockery).
Start using it for any non-trivial file ops—it’s already in our stack via Symfony’s Console component. Here’s how to migrate your current glob() calls:"To Product Managers/Designers: *"This tool lets us build faster without sacrificing reliability. For example:
.jpg files in /public and auto-compress them—no manual loops or regex headaches..md files in /content for localization, or filter files by size/modification date for cleanup.Finder::in('/storage/logs')->size('>100M')->files()).cache:clear."To Technical Leads: *"Symfony’s Finder aligns with Laravel’s architecture and reduces technical debt. Here’s how to adopt it:
glob()/scandir() for Finder in Artisan commands, service providers, or packages. Example:
// Before
$files = glob(storage_path('app/*.json'));
// After
$finder = new Finder();
$files =
How can I help you explore Laravel packages today?