Download the PHP package automattic/ignorefile without Composer
On this page you can find all versions of the php package automattic/ignorefile. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download automattic/ignorefile
More information about automattic/ignorefile
Files in automattic/ignorefile
Package ignorefile
Short Description Handle .gitignore style files.
License GPL-2.0-or-later
Informations about the package ignorefile
ignorefile
This small library allows for processing of .gitignore
-style files in PHP.
It follows the documentation at gitignore, even in cases where git itself does not.
Installation
Require using composer require automattic/ignorefile
.
Usage
Strict mode
To match git
's behavior, invalid patterns passed to add()
will be silently ignored. If you'd rather have exceptions thrown, set $ignore->strictMode
to true.
Known incompatibilities with git
As of git 2.43.0.
The fnmatch for specifics of *
, ?
, and bracket expressions.
That in turn refers to a few other documents.
Pattern | Documented | Git |
---|---|---|
a.[ |
Matches a.[ , per §2.13.1 "Otherwise, '[' shall match the character itself." |
Never matches anything. Git aborts on unclosed bracket. |
a.[x |
Matches a.[x , as above. |
Never matches anything, as above. |
a.[x\\] |
Matches a.[x] , as above. |
Never matches anything, as above. |
a.[] |
Matches a.[] , as above. |
Never matches anything, as above. |
a.[\\] |
Matches a.[] , as above. |
Never matches anything, as above. |
a.[!] |
Matches a.[!] , as above. |
Never matches anything, as above. |
a.[z-a] |
Either matches nothing or is an error, per §9.3.5 "If the represented set of collating elements is empty, it is unspecified whether the expression matches nothing, or is treated as invalid." | Matches a.z . |
Inspiration
I needed something similar to the npm module ignore
for PHP, but couldn't find one.
So I wrote one, copying the fairly comprehensive set of tests to make sure my implementation was accurate.