phug/lexer
A fast, extensible PHP lexer for Pug (Jade) templates and the Phug ecosystem. It converts template source into structured tokens for parsing, supporting indentation, tags, attributes, interpolation, code, and comments with configurable scanners.
phug/lexer is the token layer of the Phug stack — a battle-tested, MIT-licensed component that lets you buy that layer instead of owning it.dependents: 0 and 3 stars. That is not a reason to reject Phug — it is a reason to consume it through phug/renderer or phug/phug and treat the lexer as an implementation detail you do not pin, fork, or build product guarantees on.Adopt (usually indirectly) when:
Look elsewhere when:
nikic/php-parser; for arbitrary grammars, use a parser generator. Choosing a Pug-specific lexer for a non-Pug grammar is a category error.To executives: This is not a product purchase — it is a component-level build-vs-buy call worth a small amount of engineering time. The question on the table is narrow: do we need Pug template syntax in our PHP application? If yes, phug-php lets us buy a mature MIT-licensed implementation instead of building one, saving weeks of grammar work. If no, we ship nothing and stay on Blade. Cost is near zero; the real exposure is maintenance risk from a thinly adopted dependency, which we mitigate by consuming the top-level Phug package rather than this subcomponent, pinning versions, and keeping our template corpus under test. Recommendation: no action unless Pug syntax is a firm requirement.
To engineering: phug/lexer is the tokenizer in the Phug chain (lexer → parser → compiler → renderer). It is well-factored and MIT-licensed, but with 3 stars and 0 dependents it has essentially no external user base — so treat it as vendored infrastructure, not a trusted third-party service. Concretely: depend on phug/phug, not this package directly; pin exact versions; wrap the render path behind our own interface so a swap or fork is a one-file change; add regression tests over real templates before upgrading; and if we ever build tooling that needs tokens, isolate that integration so an upstream break can't reach the request path.
How can I help you explore Laravel packages today?