- What is fortephp/forte and what is it used for?
- Forte is a Laravel Blade parser and AST manipulation framework that treats Blade source as data instead of rendering it. Typical uses are custom static analysis, house lint rules, automated codemods, documentation generation from templates and bespoke templating layers on top of Blade syntax. Despite some directory listings describing it as a role and permission package, its actual scope is Blade parsing and AST manipulation. It is not meant for the request lifecycle, because Laravel already compiles views to cached PHP at render time.
- How do I install fortephp/forte with Composer?
- Forte installs like any PSR-4 Composer package: run composer require fortephp/forte in the repository where your tooling lives. Because it is a tooling dependency, prefer composer require --dev fortephp/forte so it never loads in production. Pin an exact version rather than a floating constraint, since grammar and API changes are the main upgrade risk.
- Should Forte be a production dependency or a require-dev tool?
- Keep it out of the production request path. Parsing Blade on every render would be a regression against Laravel's compiled-view cache, so Forte belongs in require-dev or a dedicated tools repository excluded from production autoloading. Confine it to CI jobs, local lint commands and one-off codemods.
- Which Laravel versions and Blade syntax does Forte support?
- Blade is a loosely specified superset of HTML and PHP, and its grammar evolves with each Laravel major, so a small third-party parser can lag behind. Before adopting, confirm explicitly which Laravel versions are supported and covered by tests. Maintain your own compatibility matrix mapping Forte version to Laravel major and PHP version, and treat every Laravel upgrade as requiring a parser re-validation gate.
- Does Forte support @verbatim, anonymous components, @props, slots and custom directives?
- Support for these constructs is exactly what you should verify in a spike rather than assume. Anonymous components, @props, slot syntax and @verbatim are common places for third-party Blade parsers to fall short, and user-defined directives often need registration or custom handling. Run a deliberately messy sample of your real views through the parser and measure the parse success rate before committing.
- Can Forte round-trip Blade templates back to source without corrupting formatting?
- Round-trip fidelity is the classic failure mode for AST libraries: serializing back can alter whitespace, attribute quoting or formatting. Ask the maintainer whether a printer exists and whether it guarantees byte-identical output or only semantic equivalence. Pre-agree a threshold, such as zero byte-level corruption across your sample corpus, before building codemods on top.
- How does Forte handle malformed or invalid Blade input?
- Error-recovery behavior matters when you are linting legacy views. Ask whether malformed input throws an exception or produces a partial AST with error nodes, since partial trees are usually more useful when scanning a large, untidy corpus. Regardless of the answer, wrap parsing in your own adapter so failures can be logged and classified consistently.
- How fast is Forte when parsing a large corpus of Blade views?
- Measure it on your own templates rather than relying on published numbers. Throughput depends on template size and grammar complexity, so benchmark a corpus of roughly one to two thousand representative views and record wall time and memory. Since this is dev tooling, the absolute figure matters less than whether it fits comfortably inside your CI budget.
- Is Forte's API stable and does it follow semantic versioning?
- Check whether releases are still pre-1.0 and whether minor versions churn the public API. Even if semantic versioning is claimed, pin an exact version and isolate Forte behind a thin internal wrapper so the rest of your tooling depends on your interface rather than Forte's. That wrapper also makes swapping or forking the parser a contained change.
- Who maintains Forte and what are the alternatives if it stalls?
- At this size the bus factor is a real concern, so confirm the actual repository, license file, CI status and test coverage before adoption. If the project stalls, the MIT license makes forking viable, and narrow fallbacks such as regex or line-based rules cover simple lint checks. Alternatives also include analysing Laravel's compiled view output or using purpose-built static analysis tooling.