Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php File Iterator Laravel Package

phpunit/php-file-iterator

php-file-iterator provides a simple, dependency-free way to filter and iterate over files by suffix, prefix, or custom filters, powering PHPUnit's test file discovery. Install it via Composer to find and list files matching patterns in any PHP project.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. phpunit/php-file-iterator is a single-purpose utility: a FilterIterator that walks a directory tree and yields files matching suffix, prefix, and exclusion rules, plus a Factory that resolves glob/globstar patterns into iterators. It has no framework coupling — no service provider, no container bindings, no configuration surface, no persistence, no I/O beyond RecursiveDirectoryIterator. That makes it architecturally harmless but also architecturally redundant for a Laravel codebase: Laravel already ships symfony/finder transitively via laravel/framework, and Finder covers the same problem space with a richer API and a far larger public documentation corpus. The realistic architecture fit is therefore not "add this to our application" but "this is already in our dependency graph as a PHPUnit implementation detail, and we should govern its version rather than adopt its API."

Integration feasibility. Trivially feasible mechanically — one composer require --dev phpunit/php-file-iterator, zero wiring. The constraint is not effort but intent. In practice the package arrives as a transitive dependency of phpunit/phpunit through phpunit/php-code-coverage; the Dependents: 0 figure in the supplied data is a Packagist reverse-dependency artifact and should not be read as "no one uses this." Feasibility for direct use is real but narrow: custom test runners, static-analysis prelinters, code-generation scanners, or CI tooling that needs to enumerate PHP files before parsing. Feasibility for application runtime use is effectively nil — using a PHPUnit-internal utility to enumerate files in a request path introduces a dev-only dependency into production bootstrap for no gain over Finder.

Technical risk. Low severity, moderate churn:

  • Aggressive PHP-version coupling. Per the release notes, v6.0.0 dropped PHP 8.2 support and v7.0.0 dropped PHP 8.3. This package tracks PHP's support window rather than offering a long compatibility tail. Any Laravel upgrade that moves the PHP floor must move this package in lockstep with PHPUnit — a coordination cost, not a correctness risk.
  • Edge-case churn in path semantics. Recent patch releases fix real traversal behavior: 7.0.2 stopped aborting on unreadable directories and stopped excluding paths that merely share a prefix with an excluded directory; 7.0.1 fixed Windows path-separator handling for hidden directories, corrected a leading-** globstar resolution bug, and pruned hidden directories instead of traversing and discarding. Several of these are correctness fixes to filtering — meaning pinning to an older minor can silently produce the wrong file set, which for a test-discovery or coverage tool is a quiet, hard-to-diagnose failure.
  • Single-maintainer concentration. Sebastian Bergmann maintains it under the PHPUnit org. Bus factor is a genuine (if well-understood) consideration, but it is mitigated by co-release with PHPUnit itself: the package cannot drift far from the ecosystem it serves.
  • Documentation depth. Maturity signals are readme and releases only. There is no API reference, no migration guide, and no documented behavioral contract for globstar, case sensitivity, or exclusion-prefix matching. Correct usage is learned from source and tests.
  • Data hygiene flag. The supplied "last release: 2026-08-25" is a future date; treat the release metadata as unreliable and confirm against Packagist before any decision.

Key questions to resolve before committing engineering time:

  1. Is the package already in composer.lock transitively, and at which major version?
  2. Does any team own code that calls Iterator or Factory directly, versus only consuming it through PHPUnit?
  3. Is there a documented requirement that Finder cannot satisfy — or is this a duplication of an existing idiom?
  4. What is our PHP floor and upgrade cadence, and does it align with this package's major-version cadence?
  5. Do we run Windows or case-insensitive filesystem CI runners, where the path-separator and case-normalization behaviors have historically been the fragile surface?
  6. Do we actually need globstar (**) semantics, or are simple suffix/prefix filters sufficient?

Integration Approach

Stack fit. Poor as a first-class Laravel dependency; acceptable as a governed dev-time transitive. The decision rule should be: this package is permitted in require-dev only when pulled by PHPUnit, and direct usage requires a written justification against Symfony Finder.

Migration path. Two directions, depending on inventory outcome:

  • If it is only transitive (expected case): no migration. The work is version alignment — upgrade it as a unit with phpunit/phpunit and never pin it independently, since independent pinning is exactly how the traversal-correctness fixes in 7.0.2 get stranded behind a newer PHPUnit.
  • If direct usage exists in product or build code: wrap it. Introduce a small internal FileEnumerator adapter exposing one method (filesIn(string $path, array $filters): iterable) implemented over this package today and over symfony/finder as the target. Migrate call sites to the adapter, then retire the dependency by swapping the implementation — a bounded change inside one class. Finder's in(), name(), notPath(), and ignoreVCS() cover the documented feature surface here almost one-to-one; the only genuinely non-obvious translation is globstar, which Finder expresses via ->path() regexes rather than ** pattern syntax.

Compatibility. Two axes must be verified per release, not assumed:

  • PHP version: this package's majors are pinned to PHP's supported window (v6 removes 8.2, v7 removes 8.3). Match our PHP floor against the package major before upgrading PHPUnit.
  • Filesystem/platform: path handling on Windows and case-insensitive macOS volumes has been the recurring defect surface. If CI includes non-Linux runners, filter assertions belong in the pipeline, not in tribal knowledge.

Lockfile is the source of truth. Add a CI check that fails when php-file-iterator resolves to a major version newer than the one bundled with our PHPUnit minor, to catch silent drift.

Sequencing.

  1. Inventory the lockfile and grep the codebase for PHPUnit\File\Iterator / Factory references to establish transitive-versus-direct.
  2. Classify each direct usage as "test tooling" (tolerated, adapter recommended) or "product runtime" (blocked; migrate to Finder).
  3. Pin and align via PHPUnit upgrade, not independent constraint.
  4. Instrument file-set determinism: snapshot the expected file list produced by test discovery and coverage configuration, so a filtering regression in an upgrade surfaces as a diff rather than as mysteriously missing coverage.
  5. Retire direct usage behind the adapter in a separate, low-risk change once step 2 confirms any consumers.
  6. Re-review at each PHP minor upgrade, since that is when this dependency's major boundary moves.

Operational Impact

Maintenance. Near-zero in the transitive case — no configuration, no runtime footprint, no service to operate. The only recurring cost is upgrade coordination with PHPUnit and PHP. In the direct-usage case the cost shifts to behavioral maintenance: undocumented glob, prefix-exclusion, and case-sensitivity semantics become institutional knowledge held by whoever last debugged a missing-test incident.

Support. Upstream is a GitHub-issues, no-LTS, no-SLA project in the PHPUnit organization. Support model is "fix released, then consumed at the next PHPUnit bump." There is no vendor to escalate to. Acceptable because the blast radius is bounded to test discovery and build tooling, and because co-release with PHPUnit means the ecosystem absorbs breakage quickly.

Scaling. Traversal is lazy and streaming — memory is O(1) in file count, so it scales fine to large repositories. Cost is dominated by filesystem I/O and stat calls, and 7.0.1 explicitly removed per-file realpath() resolution during prefix/suffix filtering, which is a meaningful throughput improvement on network and overlay filesystems. The scaling ceiling is not the iterator; it is the number of times a tool re-walks the tree. Avoid re-instantiating filters inside loops — the Iterator is immutable, with chained methods returning new instances, so a naive addExclude() in a loop allocates a fresh chain each pass.

Failure modes to watch:

  • Silently wrong file sets. The highest-impact failure. Exclusion-prefix over-matching (paths sharing a prefix with an excluded directory) was a real defect until 7.0.2 and would drop legitimate files without error.
  • Traversal aborts. Unreadable directories previously terminated the walk; 7.0.2 changed this to continue. On older pins, one permission-restricted directory can zero out a coverage run.
  • Platform-divergent filtering. Windows path-separator handling for hidden directories was broken pre-7.0.1; Linux-only CI will never surface it.
  • Globstar misparse. ** requires path separators on both sides; patterns like **.php are not recursive. A malformed pattern yields an empty or truncated set rather than an error.
  • Dev/prod leakage. If this ever appears in require rather than require-dev, a PHPUnit-internal package ships to production and becomes subject to runtime upgrade constraints it was never designed for.

Ramp-up. The API is learnable in under an hour (Iterator with addSuffix/addPrefix/addExclude, and Factory::getIterator() for globs). The realistic ramp-up is on the semantics, not the API: a new engineer will not intuit globstar boundaries, Windows separator behavior, or exclusion-prefix matching from the README alone. Mitigate by keeping exactly one file-traversal idiom in the codebase — Symfony Finder — and by documenting the adapter contract if direct usage is ever sanctioned. Onboarding cost is near zero precisely to the degree that no one on the team ever calls this package directly.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin