dflydev/ant-path-matcher
PHP implementation of Ant-style path matching. Compile glob-like patterns using **, * and ? wildcards into matchers, then test paths against them. Useful for routing, file filtering, and access rules where simple prefix checks fall short.
Str::is() / Request::is() translate * into .*, so admin/* matches admin/users/42/delete. This package preserves Ant semantics — * stays inside one segment, ** crosses segments — which is the difference between a correct and an over-permissive access rule. That makes it the right primitive for allow/deny lists, redirect allowlists, and tenant path scoping.**), and test coverage. Buy now, retain a vendoring fallback./-delimited string vs. pattern”: tenant/route scoping (/t/{tenant}/**), object-storage key allowlists (tenant-42/uploads/**/*.png), CDN/cache purge rules, webhook and post-login redirect allowlists, feature-flag targeting by path, log/metric filtering, gitignore-style asset exclusion.Str::is calls.Adopt when:
* vs ** distinction — that is the whole value proposition./-delimited strings, not only filesystem paths.Look elsewhere when:
Str::is(), Request::is(), or Route::pattern() already express the rule — a single * rule does not justify a dependency.->path(), ->notPath()).? is a single-character wildcard in Ant syntax and collides with ? in URLs. Strip or normalize query strings, or you will get surprising matches.Gates before committing: spike PHP 8.3/8.4 on your Laravel version; confirm whether URI-template variables ({var}) and extraction are supported if you want one pattern to both match and yield parameters; confirm separator behavior for non-/ delimiters and Windows-style paths. Put it behind a PathMatcher contract you own so swapping or forking is a one-file change.
Executives: A free, MIT-licensed utility that lets us express rules like admin/** and billing/* in configuration instead of hand-written regex. It closes a category of over-permission bugs: today our wildcards cross path separators, so a rule intended to protect admin/reports can also grant admin/users/42/delete. Adoption is measured in hours, not sprints, and exit cost is near zero because the code is tiny and permissively licensed.
Engineering: Framework-agnostic Ant-style matcher, zero dependencies, no Laravel version coupling. Wrap it in our own PathMatcher interface, pin the version, and add a pattern-compilation cache if it lands in hot middleware. Upstream looks dormant — 6 stars, no dependents, last release 2023 — so plan the fork: copy the class into app/Support/ with attribution. That fallback is roughly half a day and we should scope it now, not after an incident.
State the caveats up front: unproven in the wild, no benchmarks, dormant maintainer, and ?-as-wildcard is a genuine footgun for URL matching. Recommendation: adopt for config-driven, non-hot-path matching — ACLs, allowlists, cache and purge rules — not as the backbone of request routing.
How can I help you explore Laravel packages today?