Getting Started
Globby is a PHP library for file pattern matching using glob patterns, similar to how shells match files.
Installation
Section titled “Installation”composer require cline/globbyBasic Usage
Section titled “Basic Usage”use Cline\Globby\Globby;
// Find all PHP files$files = Globby::find('**/*.php');
// Find files in specific directory$files = Globby::find('src/**/*.php');
// Find multiple patterns$files = Globby::find(['**/*.php', '**/*.js']);Pattern Syntax
Section titled “Pattern Syntax”| Pattern | Description |
|---|---|
* | Match any characters except / |
** | Match any characters including / |
? | Match single character |
[abc] | Match characters in brackets |
[!abc] | Match characters not in brackets |
{a,b} | Match any of the patterns |
Examples
Section titled “Examples”// All PHP files recursivelyGlobby::find('**/*.php');
// PHP files in src only (not subdirs)Globby::find('src/*.php');
// Test filesGlobby::find('tests/**/*Test.php');
// Config files (json or yaml)Globby::find('config/*.{json,yaml}');
// All files except vendorGlobby::find('**/*', exclude: ['vendor/**']);Next Steps
Section titled “Next Steps”- Basic Usage - Common patterns and examples
- Filtering Options - Filter results
- Gitignore Integration - Respect .gitignore
- Advanced Patterns - Complex matching