Latest release: none
A utility implementing Git-like globbing. Wildcards in the glob match any number of characters (zero or more), including directory separators.
The main class of the package is Glob
. Use Glob::glob()
to glob the
filesystem:
use Webmozart\Glob\Glob;
$paths = Glob::glob('/path/to/dir/*.css');
You can also use GlobIterator
to search the filesystem iteratively. However,
the iterator is not guaranteed to return sorted results:
use Webmozart\Glob\Iterator\GlobIterator;
$iterator = new GlobIterator('/path/to/dir/*.css');
foreach ($iterator as $path) {
// ...
}
The package also provides utility methods for comparing paths against globs.
Use Glob::match()
to match a path against a glob:
if (Glob::match($path, '/path/to/dir/*.css')) {
// ...
}
Glob::filter()
filters a list of paths by a glob:
$paths = Glob::filter($paths, '/path/to/dir/*.css');
The same can be achieved iteratively with GlobFilterIterator
:
use Webmozart\Glob\Iterator\GlobFilterIterator;
$iterator = new GlobFilterIterator('/path/to/dir/*.css', new ArrayIterator($paths));
foreach ($iterator as $path) {
// ...
}
Use Composer to install the package:
$ composer require webmozart/glob@dev
Contributions to the package are always welcome!
- Report any bugs or issues you find on the issue tracker.
- You can grab the source code at the package's Git repository.
If you are having problems, send a mail to bschussek@gmail.com or shout out to @webmozart on Twitter.
All contents of this package are licensed under the MIT license.