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.
Architecture fit. This is a contracts-only package: interfaces and types for the phplrt lexer, with no implementation. Architecturally that makes it the clean seam of the lexer subsystem — a place to depend on behavior without coupling to phplrt's concrete Lexer, and the natural extension point if we ever write our own tokenizer. Fit is high only inside a phplrt- or parser-centric codebase; outside that, it is inert.
Integration feasibility. Trivially installable (composer require phplrt/lexer-contracts), but the honest assessment is that we rarely need it directly: it arrives transitively with phplrt/phplrt. A direct dependency is justified only when we implement the lexer contracts ourselves or wrap a replacement lexer behind them. Effort is low; the real question is whether it is necessary.
Technical risk. Code-level risk is low — interfaces, MIT license, no runtime logic, no dependency surface of its own. The risk is concentrated in provenance. The repository is explicitly a READ-ONLY subtree split generated from the phplrt/phplrt monorepo, which means issues, PRs, and releases originate upstream while this artifact shows 1 star and 0 dependents. The split-repo metrics understate relevance relative to the parent project, but they accurately signal a very small community and effectively single-maintainer governance. The primary technical failure mode is version skew between these contracts and the phplrt implementation, since type signatures must match exactly.
Key questions.
phplrt/phplrt actively maintained, and which major line can we commit to?Stack fit. PHP with Composer, targeting the PHP version constrained by the resolved phplrt release. It fits any PHP service or tool that needs tokenization or grammar-driven parsing — static analysis, DSLs, templating, config languages. It deliberately does not fit non-PHP stacks, and it does not provide parsing capability by itself; that lives in the parent package.
Migration path. If phplrt is already present, there is nothing to migrate — the contracts resolve alongside it. If we are moving off doctrine/lexer, nikic/php-parser token streams, or a hand-rolled scanner, the pragmatic path is an adapter: implement the contract interfaces in a thin facade over the existing tokenizer, verify parity with a token fixture suite, then replace the engine underneath. This keeps migration reversible and isolates the interface boundary.
Compatibility. Because the package is generated from the monorepo, contracts versions track phplrt majors. Align the two explicitly, verify the PHP constraint overlap before pinning, and confirm the split tag actually exists for the chosen release — split repos occasionally lag. If Composer reports a conflict between a transitive and a direct constraint, the direct one wins and the phplrt version must move with it.
Sequencing.
composer.json and CI.Maintenance. Ongoing cost for this package is near zero: interfaces are the most stable part of a parser library. The friction is procedural — because the repo is read-only, any defect or API request must be filed against the monorepo, and a local patch would have to be carried as a fork or a Composer VCS entry. Budget a small coordination allowance rather than engineering hours, plus one upgrade ticket per major release.
Support. This is the weakest dimension. One effective maintainer, a split artifact with 1 star and 0 dependents, and no commercial backing imply a bus factor of one. The mitigations are cheap and worth doing: wrap the interfaces in our own adapter so the blast radius of abandonment is a compile-time swap, and keep the ability to vendor a patched copy.
Scaling. No runtime cost — interfaces add autoload entries and nothing more. Any scaling conversation (streaming huge inputs, memory on large token streams, cursor reuse) belongs to the lexer implementation, not to these contracts. Do not let this package appear in performance or capacity planning.
Failure modes.
Ramp-up. For consumers, negligible — an engineer can read the interfaces in under an hour. For anyone implementing or extending a lexer, expect roughly half a day for a senior PHP engineer to absorb phplrt's cursor-and-position model and become productive against the contracts, plus additional time to learn the monorepo/subtree-split contribution workflow, which is not obvious from this repository alone. Document that workflow internally once, rather than rediscovering it per contributor.
How can I help you explore Laravel packages today?