phug/compiler
Phug Compiler is the core compiler for the Phug (Pug/Jade) template engine in PHP. It parses Pug's concise, indentation-based syntax and compiles templates into fast, cacheable PHP code, with support for custom dialects, extensions, and Laravel integration.
Architecture fit. phug/compiler is the code-generation stage of the Phug Pug/Jade pipeline: lexer → parser → AST → compiler → emitted PHP template classes. As a discrete compiler it maps cleanly onto the same pattern Laravel developers already trust in Blade (view:cache, compiled PHP under storage/framework/views), so conceptually it is not an exotic dependency. It is also a pure package — it does not own rendering, caching, or HTTP integration, which means the Laravel-facing concerns live in sibling packages (phug/renderer, the Laravel adapter). For a TPM this is good separation but a scoping trap: approving phug/compiler means approving a family of packages that must move together.
Integration feasibility. Feasible but non-trivial. You need: a writable compiled-template directory, a cache-invalidation strategy hooked into deploy, a view-finder adapter so view('foo') resolves .pug files, and a decision on whether compilation happens at request time (first-hit cost, write permissions in production) or at build time (adds a build step and a compiler dependency in CI). All are solvable; none are free.
Technical risk.
composer update..pug source, unless source-line mapping is wired through your error handler. Stack traces from compiled templates are materially harder to read than Blade's.Key questions for the maintainer/team.
phug/parser, phug/lexer, and phug/renderer does this release pin, and is there a compatibility table?Stack fit. Reasonable only if the team has a concrete reason to prefer Pug's indentation-based syntax over Blade — typically designers porting existing Pug templates from a Node front end, or a JS/TS-adjacent team with Pug muscle memory. If the motivation is "Blade feels verbose," the answer is Blade components, not a second templating engine.
Migration path. Do not convert existing Blade. Run both engines side by side, route new or recently-rewritten views through Pug behind a view.engine config, and let the Blade surface shrink naturally. A big-bang conversion of a mature Blade codebase is a high-cost, low-return project with a long tail of subtle escaping and directive differences.
Compatibility. Confirm the package supports your PHP minor and Laravel major before scoping anything else; this ecosystem trails Laravel releases. Ensure compiled templates land in a directory that is (a) writable by the deploy user, (b) excluded from git, and (c) cleared in your release script alongside view:clear. Watch for opcache: with opcache.validate_timestamps=0 in production, a stale compiled template will persist until the FPM worker recycles.
Sequencing.
pug-lint equivalent) before any team member writes a template.Maintenance. Low code-churn but non-zero ownership. Budget for a quarterly version-alignment review across the phug family and a standing assumption that you will debug compiler internals yourself at least once. Pin exact versions, not caret ranges, and treat upgrades as code changes requiring review.
Support. There is no vendor. Support is the maintainer's issue tracker plus your own team. For a small team this is fine on a low-traffic marketing surface and unacceptable on a revenue-critical path. Position it accordingly.
Scaling. Compilation is CPU-bound and one-time per template version, so runtime scaling is a non-issue if you precompile. If you compile lazily, the first request after each deploy pays a compile cost per template — on a cold autoscaled fleet this creates a thundering-herd compile spike and can trip health checks. Precompile in the build artifact; never rely on lazy compilation in production.
Failure modes.
composer update → compile failures on deploy, invisible in staging if staging's cache is warm.Ramp-up. Two to three days for a developer fluent in Blade to become productive in Pug; longer to become safe with mixins, includes, and interpolation-escaping defaults, which differ subtly from Blade's {{ }}. Add a linting step to CI and a short internal style guide. The hidden cost is review: most reviewers will not read Pug fluently, so template PRs get rubber-stamped. Assign a small group of template owners rather than letting the whole team write Pug.
Overall. Technically credible, well-factored compiler with a clean conceptual analogue in Blade — but a thin ecosystem, single-maintainer risk, and lockstep dependency management. Justifiable as a targeted, precompiled, non-critical-surface choice; not justifiable as a default templating strategy for a Laravel product.
How can I help you explore Laravel packages today?