A user-friendly glob matching library for PHP, inspired by sindresorhus/globby. Features multiple pattern support, negation patterns, gitignore integration, and a fluent configuration API.
Requires PHP 8.4+
composer require cline/globby- Basic Usage - Pattern matching fundamentals, multiple patterns, negation, and streaming
- Filtering Options - Files vs directories, dotfiles, depth limiting, and path formatting
- Gitignore Integration - Respecting .gitignore rules and custom ignore files
- Advanced Patterns - Brace expansion, character classes, globstar, and escaping
| Option | Type | Default | Description |
|---|---|---|---|
cwd |
string |
getcwd() |
Current working directory |
expandDirectories |
bool|array |
true |
Auto-expand directories to glob contents |
gitignore |
bool |
false |
Respect .gitignore rules |
ignoreFiles |
string|array |
null |
Custom ignore file patterns |
ignore |
array |
[] |
Additional patterns to ignore |
onlyFiles |
bool |
true |
Match only files |
onlyDirectories |
bool |
false |
Match only directories |
dot |
bool |
false |
Include dotfiles |
deep |
int |
null |
Maximum traversal depth |
followSymbolicLinks |
bool |
true |
Follow symbolic links |
suppressErrors |
bool |
false |
Suppress file system errors |
absolute |
bool |
false |
Return absolute paths |
unique |
bool |
true |
Deduplicate results |
markDirectories |
bool |
false |
Add trailing slash to directories |
caseSensitiveMatch |
bool |
true |
Case-sensitive pattern matching |
baseNameMatch |
bool |
false |
Match patterns against basename only |
throwErrorOnBrokenSymbolicLink |
bool |
false |
Throw error on broken symlinks |
objectMode |
bool |
false |
Return GlobEntry objects instead of strings |
stats |
bool |
false |
Include file statistics (implies objectMode) |
fs |
FileSystemAdapter |
null |
Custom file system adapter |
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
The MIT License. Please see License File for more information.