philippn / file-collect-import
dev-main
2026-11-20 22:49 UTC
Requires
None
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-20 20:50:38 UTC
README
Collect text files from a project using include and exclude patterns.
Naming conventions
Any file name starting with _ is an internal implementation file and must never be used directly.
Use the public API instead.
Usage
FilesContext::***()
Patterns
Patterns are relative to the collection root and match files only.
| Pattern | Meaning |
|---|---|
index.php | Exact file in the root |
src/index.php | Exact relative file path |
*.php | PHP files in the root |
src/*.php | PHP files directly inside src |
**.php | PHP files at any depth, including the root |
ENV/** | All files under ENV, at any depth |
Wildcards
*— zero or more characters, excluding/.**— zero or more characters, including/.
Patterns must match the complete relative file path. Matching is case-sensitive.
Directories are traversal mechanisms only; patterns select files, never directories.
Exclusions
Prefix a pattern with ! to exclude matching files.
- All inclusion patterns are processed first.
- All exclusion patterns are applied afterward.
- Exclusions always take precedence, regardless of rule order.
- Exclusions filter already-selected files and never initiate traversal.
Example:
[
'**.php',
'config/**',
'!vendor/**',
'!**.min.php',
]
Built-in exclusions
The collector always excludes:
- Directories:
.git,.idea - Files:
composer.lock .env*files, except names containing.dist.or ending in.dist- File suffixes:
.min.js,.min.css - Binary files
- Symbolic links
Examples:
| Filename | Result |
|---|---|
.env | Excluded |
.env.local | Excluded |
.env.production | Excluded |
.env.dist | Included |
.env.dist.local | Included |
.env.local.dist | Included |
Collection behavior
- Exact patterns resolve directly to files.
- Wildcard patterns traverse from the longest literal directory prefix.
- No project-wide file index is built.
- File contents are read after selection, exclusion filtering, and confirmation.