Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Ast Laravel Package

phug/ast

phug/ast provides the abstract syntax tree node classes that power the Phug Pug/Jade template engine for PHP. It defines the structured node types produced by the parser, enabling analysis, transformation, and compilation of templates.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. phug/ast is not a standalone product; it is the node/tree substrate underneath the Phug template engine (a PHP port of Pug/Jade). It provides the AST node model, tree traversal/iteration primitives, and mutation helpers that phug/parser and phug/compiler build on. That makes the fit decision binary rather than gradual: it is worth adopting only if we are (a) embedding Phug as our template layer, (b) writing custom Phug parser extensions/filters that must emit or transform nodes, or (c) building tooling (linters, formatters, static analyzers, template migrators) over Pug source. If none of those hold, there is no architectural reason to take a direct dependency — we would inherit an internal implementation detail of someone else's engine with no independent value.

Integration feasibility. Mechanically trivial: MIT licensed, Composer-installable, PSR-4 autoloaded, no native extensions, no external services. The real feasibility question is API stability, not install friction. This is a low-level package whose consumers are the sibling Phug packages, so its public surface has historically been shaped by internal needs rather than external contracts. We should assume the documented API is thin and that the practical contract is "whatever the parser and compiler call."

Technical risk. High relative to the value delivered:

  • Bus factor. 2 stars and 0 recorded dependents is a weak but not disqualifying signal for a sub-package (transitive consumers rarely register), yet the surrounding ecosystem is small and appears maintainer-concentrated. Single-maintainer abandonment is the dominant risk.
  • Semantic versioning exposure. Because the package exists to serve its siblings, minor releases may carry changes that are non-breaking for Phug but breaking for third-party node manipulation. We cannot rely on semver as a safety net.
  • Coupling to internals. Any custom visitor we write is coupled to node class hierarchies and traversal ordering that are not marketed as stable.
  • Release cadence. The 2026-03-15 release date indicates active maintenance, which partially offsets the adoption risk — but activity is not the same as external-API discipline.

Key questions for the maintainer / spike.

  1. Which node and traversal types are considered public API versus internal, and is that boundary documented?
  2. What is the supported PHP version matrix, and what is the deprecation policy as PHP majors move?
  3. Are traversal order, visitor semantics, and node mutability guaranteed stable across minor versions?
  4. Is there a security disclosure channel, and does the project have a CVE history?
  5. Does the Phug meta-package pin this dependency tightly, or float it? (Determines whether we can even control our exposure.)
  6. What is the realistic upgrade path if the upstream project stalls — is the AST format simple enough to fork and vendor?

Integration Approach

Stack fit. Laravel/PHP applications already carry a template layer (Blade). Adopting Phug means running a second template engine alongside Blade, with its own caching, escaping rules, and error surface. That is a legitimate choice only for a bounded use case — e.g., ingesting designer-authored Pug assets, or a migration tool that compiles legacy Pug to Blade/Twig. It is not a sensible default for application views.

Migration path. Do not adopt phug/ast directly. Take it transitively via phug/phug or phug/parser so version resolution stays with the ecosystem, then constrain it explicitly in composer.json if we touch node APIs. If we only consume compiled output, phug/ast never appears in our code at all and the risk is contained to the dependency chain.

Compatibility. Verify PHP constraint alignment with the Laravel version in use before anything else; this is the most common blocker for PHP template-engine packages. Confirm the package does not require extensions we do not ship, and check that its autoloading does not collide with Blade's compiler pipeline or Laravel's view cache.

Sequencing.

  1. Spike (1–2 days): install in a scratch Laravel app, compile a representative Pug corpus, exercise a custom visitor against the node API.
  2. Decide: if the spike requires touching internal node classes, treat the integration as a fork-and-own decision, not a dependency decision.
  3. Isolate: wrap all Phug interaction behind an internal TemplateRenderer boundary so the engine is swappable and the blast radius of an upstream break is one class.
  4. Pin: exact-version pin phug/ast and its siblings; no caret ranges on packages we manipulate directly.
  5. Instrument: add a conformance test suite over our Pug corpus that runs in CI on every dependency bump.

Operational Impact

Maintenance. Near-zero if consumed transitively and never called directly — dependency bumps ride along with Phug upgrades. If we manipulate nodes directly, maintenance cost is material: every Phug release becomes a code review of node/traversal changes, and we own compatibility shims we did not budget for.

Support. Community-only, no commercial backing, no SLA, no vendor to escalate to. Internal runbooks must assume we are on our own for anything beyond "it works" — including security triage. Given a 2-star footprint, Stack Overflow and blog coverage will be sparse; the source is the documentation.

Scaling. Runtime cost is negligible in the request path — AST construction and traversal happen at compile time, and compiled templates are cached. The scaling concern is memory during compilation of very large or deeply nested templates (recursive traversal on pathological nesting) and compile-time CPU on cold cache. Bound template size, precompile in CI where possible, and ensure the view cache is warm across the fleet to avoid compile storms after deploys.

Failure modes.

  • Silent output drift after a minor upgrade changes traversal or escaping semantics — mitigated by golden-file tests on rendered output, not just "does it compile."
  • Fatal on PHP upgrade if the package lags a PHP major — mitigated by pinning and by keeping the boundary class small enough to swap.
  • Upstream abandonment — mitigated by vendoring the package into the repo if direct node manipulation becomes load-bearing; the AST model is small enough that a fork is tractable.
  • Dual-engine confusion — two escaping/caching models in one codebase invites XSS mistakes; require that all Phug output flows through one reviewed adapter.

Ramp-up. Low for "use Phug as a template engine" (hours). High for "extend the AST" — node hierarchies, visitor semantics, and traversal order are learned by reading source and sibling packages, not from docs. Budget a senior engineer for the spike, and treat any estimate that assumes external documentation as optimistic. The low opportunity score (27.96) alongside a moderate overall score (7.46) is consistent with this read: competent, actively maintained, but a narrow tool whose value is confined to teams already committed to Pug-in-PHP.

Recommendation. Conditional adopt, transitive only. Green-light as part of a Phug evaluation for a specific, bounded use case (designer Pug ingestion or migration tooling). Do not adopt as a direct dependency, do not build core application rendering on it, and gate any node-level extension work behind the spike and a fork contingency plan.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin