phug/parser
phug/parser is the PHP parser behind Phug, converting Pug/Jade template source into an abstract syntax tree. It tokenizes and parses Pug syntax—tags, attributes, expressions, mixins, includes—for the Phug rendering engine.
Architecture fit
phug/parser is not a standalone solution — it is one node in the Phug Pug/Jade toolchain (lexer → parser → AST → compiler → renderer → formatter). A Laravel team that installs only phug/parser gets an AST builder with no render path, no view integration, and no cache layer. The architecturally correct dependency is the phug/phug meta-package (or at minimum phug/renderer), with phug/parser treated as a transitive detail. Any design that names phug/parser directly in composer.json should be treated as a smell.
Fit is narrow but legitimate: Laravel's view layer is pluggable, and Pug's indentation-based syntax is genuinely attractive for design-heavy marketing pages, transactional email HTML, and static-style content where Blade's @directive noise degrades designer ergonomics. It is a poor fit for application UI, Livewire/Inertia surfaces, or anything where Blade component semantics and Laravel's first-party tooling (view caching, @vite, Blade components) are load-bearing.
Integration feasibility
Technically straightforward: Composer install, PHP 8.x, an Illuminate\View\Engines\EngineInterface implementation registered via a service provider, and a custom view finder for .pug extensions. Coexistence with Blade is achievable by scoping Pug to a separate view namespace (e.g. resources/views/pug/) rather than swapping the default engine — this keeps blast radius contained and avoids a flag-day migration.
The real feasibility risk is the ecosystem gap, not the code. With 4 stars and 0 dependents, there is no evidence of production Laravel usage to borrow from: no maintained first-party Laravel bridge in this metadata, no community integration patterns, no known-good service provider to copy. We would be writing and owning the Laravel glue ourselves, and that glue is where 80% of the operational cost will live.
Technical risk
phug-php/reader) does not correspond to the package identity (phug/parser). This must be resolved before any dependency audit; an incorrect or renamed source of truth is a supply-chain question, not a clerical one.Key questions
phug/parser named rather than phug/phug? Is this a deliberate slice or a misidentified dependency?phug-php/reader or a phug-php/parser repo? Who controls it?Stack fit
Assume Laravel 10/11/12 on PHP 8.2+. Pug should be introduced as a secondary engine behind an isolated view namespace, never as the default. Blade remains the engine for all application UI; Pug is confined to a defined content class (marketing pages, email templates). This preserves first-party tooling and keeps the decision reversible.
Migration path
Do not migrate existing Blade views. There is no incremental Blade→Pug path, and rewriting working views to a 4-star dependency inverts the risk/reward. Instead:
phug/phug (not phug/parser) with an exact version constraint, committed composer.lock, and a documented upgrade procedure.view:clear-equivalent for the Phug cache.Compatibility
@vite/@livewire inclusion strategies, and localization in email templates.Sequencing
| Phase | Scope | Gate |
|---|---|---|
| 0 | Repo/package provenance audit; license and supply-chain review | Authoritative source confirmed |
| 1 | Spike: adapter + one email template, snapshot-tested | Renders identically in web and queue contexts |
| 2 | Hardening: cache strategy, CI job for pug lint/compile, PHPStan coverage |
Cache shared across containers; no cache-related failures in staging |
| 3 | Piloted rollout, 3–5 templates, one team | ≤1 hour ramp-up per dev; no parse-error incidents in 2 sprints |
| 4 | Expand or deprecate | Decision recorded |
Exit criteria for Phase 3 → 4 should be written down before Phase 1: no upstream commits in 6 months, a security advisory without a patch, or more than one production incident attributable to the engine all trigger removal.
Maintenance
The recurring cost is not the package — it is the adapter, the cache lifecycle, and the version-pinning discipline. Expect an ongoing ~2–4 hours/month of platform-team attention, mostly upgrade testing and cache debugging. We own the Laravel glue indefinitely; upstream will not maintain it for us. Pin exactly, never use floating constraints, and treat upstream tags as code review events.
Support
Community-only, no SLA, small maintainer pool. Internally this must be owned by a named platform engineer with a documented fallback: extract Pug templates to plain PHP/HTML, delete the adapter, remove the dependency. That fallback should be rehearsed once in staging; if it takes more than a day, the dependency is too entrenched.
Scaling
Template compilation is CPU-bound and one-time per template version, so the steady-state cost is near zero — but only if the compile cache is warm and shared. Cold-cache behaviour on autoscaling or blue-green deploys is the scaling hazard: every new container recompiles every template on first hit. Mitigate by precompiling at build time (php artisan pug:compile in CI, artifact baked into the image) rather than lazily at runtime. If precompilation is not achievable, write the cache to a shared Redis/EFS volume and accept the network hop.
Failure modes
.pug files on every commit; this converts a runtime failure into a build failure and is the single highest-value control..pug files live only in the repo and pass code review.Ramp-up
Blade-fluent developers will need roughly half a day to become productive in Pug (indentation significance, mixins, interpolation, PHP expression syntax) and about a week to become idiomatic. Designers familiar with Jade/Pug onboard faster than engineers. Budget for a short internal guide covering our adapter's config, the cache-clear command, the CI lint step, and the "which engine do I use for this view" decision rule. Without that decision rule, teams will drift and you will end up with a two-engine codebase with no coherent boundary.
Recommendation: proceed to Phase 0–1 as a time-boxed spike only. The scores — 4 stars, 0 dependents, opportunity 23.12 — describe a niche component with no ecosystem reinforcement, and the gain over Blade is developer ergonomics rather than capability. Justify it with a concrete Pug corpus or designer-workflow requirement, or decline.
How can I help you explore Laravel packages today?