phlak/splat
Splat is a lightweight PHP library for matching strings against wildcard patterns. It provides simple, expressive helpers for route-style matching, capturing wildcard segments, and filtering paths or values, making it useful for routing, file matching, and other pattern-based tasks.
**, brace expansion {a,b}, escaping, and Windows vs. POSIX separators are a multi-day edge-case project. This package turns that into a one-line composer dependency and lets engineering spend the time on the actual feature.PathMatcher-style interface keeps the vendor choice non-load-bearing, so this is a low-regret decision even if we swap implementations later.Adopt when:
**) and/or brace ({a,b}) matching — the two things fnmatch() and Laravel's Str::is() do not cover.Look elsewhere when:
.gitignore semantics — negation, anchoring, directory-only rules. Glob is not gitignore; conflating them creates subtle, user-visible bugs.* wildcards → Str::is() or fnmatch(); no dependency is justified.Risks to price in: ~106 stars and a small maintainer base mean real bus-factor risk. The source is small enough to audit in an afternoon — do that, pin the version, and wrap it. Also validate behavior with user-supplied patterns before exposing them broadly: pathological patterns and separator handling are where this class of library typically bites.
To executives: This is a tiny, MIT-licensed utility that lets us ship flexible file and path rules — include/exclude patterns — in [feature] without a bespoke engineering project. The cost is one composer dependency; the risk is low and reversible because it sits behind our own interface and touches no data models, auth, or infrastructure. It converts a "someday" roadmap item into a sprint-sized one.
To engineering: Standalone PHP, no Laravel coupling, no service provider, small surface. It covers recursive and brace-expanded glob patterns that fnmatch and Str::is can't, which is the whole reason to take the dependency. Keep Symfony Finder for traversal if we need it; use this strictly for matching. Wrap it in a PathMatcher interface so we can swap to Finder or a regex-based implementation if throughput or semantics demand it. Add tests for Windows separators, **, braces, and hostile user input, and cap pattern complexity at the boundary.
Recommendation: Adopt narrowly, behind an interface, with a documented fallback path.
How can I help you explore Laravel packages today?