webmozart/glob
Ant-like globbing for PHP with support for , ?, [], {}, and // to match directories. Glob filesystem paths (including stream wrappers), match globs against strings, and filter path arrays. Uses native glob() when possible; throws on invalid patterns.
Architecture fit: Excellent standalone utility for Laravel's filesystem operations. Complements Symfony components already in Laravel stack. Stream wrapper support aligns with Laravel's storage drivers (S3, FTP, etc.). No framework dependencies or service container requirements.
Integration feasibility: Extremely low friction. Simple Composer dependency. Can be used directly via Glob::glob() or injected. Works seamlessly with Laravel path helpers (base_path(), storage_path()).
Technical risk: Low. Mature package (last release 2024-03-07), handles edge cases (Windows, musl), and falls back to native glob() for performance. Primary risk is regex-based scanning for complex patterns in high-frequency paths.
Key questions: How does it handle symbolic links? Does it support depth-limited recursion beyond /**/? Are there performance implications for 100k+ file scans in production?
Stack fit: Ideal for Laravel tasks requiring advanced glob patterns (e.g., view discovery, asset compilation, plugin scanning). Works with storage_path(), public_path(), and custom stream wrappers like s3://.
Migration path: Replace native glob() calls where advanced syntax is needed (e.g., {a,b}, /**/). Start with non-critical paths (e.g., config discovery), then scale to performance-sensitive areas. Use Glob::filter() for array-based path processing.
Compatibility: Requires PHP 7.3+ (Laravel 8+ compatible). Paths must be absolute (use Laravel helpers). Forward slashes enforced - no Windows path issues.
Sequencing: 1) Audit existing glob() usage for pattern limitations. 2) Replace with Glob::glob() for specific use cases needing {} or /**/. 3) Benchmark against native glob() for hot paths. 4) Use iterators for large directory scans.
Maintenance: Minimal. Stable release history (1-2 releases/year), no breaking changes in recent versions. No Laravel-specific maintenance needed. Dependents count of 0 is misleading (used internally by many projects).
Support: GitHub issue-based support. Documentation is thorough. No dedicated Laravel support but simplicity reduces support overhead. Community activity is moderate (257 stars, 1 contributor in last release).
Scaling: Handles large directories via GlobIterator (streaming results). Recursive patterns (/**/) may slow for deep trees - avoid in high-throughput paths. Native glob() fallback ensures baseline performance for simple patterns.
Failure modes: Invalid syntax throws InvalidArgumentException (must be caught for user-facing ops). Unreadable directories may fail silently (depends on PHP's glob() behavior). Stream wrapper failures require specific error handling.
Ramp-up: Low. Developers familiar with glob syntax adapt quickly. Critical to document escaping rules (\\\\ for literal \) and Windows path normalization. Training should emphasize absolute paths and iterator usage for large datasets.
How can I help you explore Laravel packages today?