phplrt/lexer-contracts
phplrt/lexer-contracts defines the core interfaces and contracts for building lexers within the phplrt ecosystem. It provides a clean, type-safe foundation for tokenizing source code, letting you implement custom lexers that integrate seamlessly with phplrt parsers and tooling.
phplrt/phplrt, these contracts let us expose a public "bring your own lexer" extension point without forcing consumers to install the whole parser framework. That's a product decision about how open our integration surface is, made at near-zero dependency cost.phplrt/lexer. The decision it informs is whether to define our own lexer interface or adopt a pre-existing one that already has an implementation behind it.require block tiny and avoids coupling our users to a specific tokenizer. That is a real packaging/roadmap choice, not a technicality.Consider it when:
phplrt and need a custom Lexer implementation that interoperates with its parser stack.Look elsewhere when:
phplrt/lexer or phplrt/phplrt directly. This package gives us nothing to run.phplrt. nikic/php-parser, doctrine/lexer, or a 200-line hand-rolled tokenizer is a better fit, and avoids inheriting a low-traction dependency.phplrt/phplrt monorepo — fixes and PRs must go upstream, and version numbers track the monorepo, not this package's own release cadence. If we need to fork and modify, we fork the monorepo and lose the "tiny dependency" benefit entirely.Adoption criteria before we commit: pin an exact version, wrap it in our own adapter interface so no application code imports Phplrt\Lexer\* directly, and confirm upstream is actively maintained (last release, issue responsiveness) since the split repo itself carries almost no independent signal.
To executives: This is a small, MIT-licensed PHP package that defines interfaces for a lexer — the tokenizing stage of a parser. It adds essentially no code to our runtime and no licensing cost. It is worth adopting only as an internal seam: it lets us offer a pluggable, swappable tokenizer in parser-based products while keeping our dependency footprint clean. The caveat is maturity: the standalone repo shows 1 star and 0 dependents, and it is a read-only mirror of a larger monorepo, so its health is entirely the health of that upstream project. Recommendation: use it at the boundary, not at the core; do not build a roadmap commitment on it.
To engineering: Contracts-only, interfaces for lexers. Value is that we can accept a lexer without depending on a concrete tokenizer, which makes testing and multi-backend support straightforward. Constraints: it's a subtree split — no direct PRs here, versioning follows phplrt/phplrt, and it ships no behavior (you still need phplrt/lexer). Proposed pattern: our own thin adapter interface wraps these contracts so replacement is a one-file change, and we pin versions explicitly rather than floating.
To product/design: The practical payoff is that parser-based features (template syntax, query languages, custom formats) can support customer- or team-supplied tokenizer extensions later without re-architecting. That optionality is cheap now and expensive to retrofit, which is the entire argument for the dependency.
How can I help you explore Laravel packages today?