Skip to content

PHPantom — Blade

Known gaps and planned features in PHPantom's Laravel Blade template support. For Eloquent model support see laravel.md. For the shipped preprocessor pipeline and module layout see ARCHITECTURE.md.

The strategy, implemented in src/blade/: preprocess .blade.php files (recognised by URI suffix, or by a did_open languageId of "blade") into valid virtual PHP, feed the virtual PHP through the existing pipeline (parser, resolver, completion, definition), and map response positions back to the original Blade file through a source map. Every item below builds on that pipeline.

Items are ordered by impact (descending), then complexity (ascending) within the same impact tier, with a dependent item placed after its dependency.

Label Scale
Impact Critical, High, Medium-High, Medium, Low-Medium, Low
Complexity Low (mechanical/boilerplate, no design decisions), Medium (self-contained, follows an existing pattern), Medium-High (spans modules, some new design), High (shared/core subsystem, correctness or performance tradeoffs), Very High (cross-cutting architecture, wide blast radius)

Out of scope (and why)

Item Reason
Editor-side Blade language registration The tree-sitter grammar, .blade.php file association, and languageId: "blade" wiring belong to editor extensions, not the server. Zed's official PHP extension (which absorbed PHPantom's plain-PHP wiring; this repo no longer bundles zed-extension/) will not grow Blade support — that registration belongs to a third-party Blade extension instead, which already exists (zed-laravel-blade, MIT, unaffiliated) and lists PHPantom as one of several selectable language servers alongside Intelephense, PhpTools, and Phpactor. On VS Code, Blade extensions already set languageId to "blade", so PHPantom's integration needs to register for both "php" and "blade". Neovim's lspconfig can be configured to send .blade.php files with the correct languageId.
Rendering or booting to resolve templates Consistent with laravel.md: we never run PHP or boot a Laravel application.

Philosophy

  • No application booting. Consistent with laravel.md. We never run PHP or boot a Laravel application.
  • Signatures over call-site scanning. A template's variable types come from its declared contract: the Bladestan-compatible chain in src/blade/signature.rs — @bladestan-signature docblock, first docblock before template code, @props/@aware, Blade's own component scope, the backing component class, and the layouts the template @extends. The template declares what it expects; call sites are then validated against that contract (src/blade/contract.rs and src/diagnostics/blade_call_site.rs), exactly as a function signature works. Inferring types from call sites inverts the contract and produces "true for one caller" types, so it is not the foundation — the shipped call-site inference fallback for unannotated projects is layered strictly below every declared source. Projects running Bladestan (a PHPStan extension for Blade template analysis) get the full contract model in both the editor and CI from the same annotations.
  • Discovery is just directory walks. Walking the configured view roots and the directories the component namespaces live in (src/blade/discovery.rs) is the full extent of external Blade file discovery. Paths are converted to view names and component names via string transforms. A namespace no PSR-4 mapping of the project's own composer.json covers (a vendor package that registered a component namespace) is read off the class index instead, since there is no directory to walk for it.
  • PSR-4 says where a namespace lives, not what a component is called. A mapping resolves App\View\Components to the directory to walk, and once we know an FQN (e.g. App\View\Components\Alert) the existing find_or_load_class pipeline reads its source. The names themselves always come from the file paths.
  • Graceful degradation. Unknown directives become comments. Failed component resolution produces comments. The user always gets partial completions rather than a broken file. The preprocessor must never produce invalid PHP.

BL20. Port Bladestan's tests

Impact: Medium · Complexity: Medium

PHPantom reads the same template contract Bladestan does (the @bladestan-signature chain, @props/@aware, component scope, layouts), but checks it only against tests of its own. Bladestan's suite covers the variables a template sees, from its signature, its component, and its layouts, and the errors it reports for them. Port its fixtures into tests/fixtures/bladestan/ as diagnostics and hover fixtures run by tests/fixture_runner.rs, with a project under tests/bladestan/ holding the views and the slice of laravel/framework they need, and file every case PHPantom answers differently as a // SKIP: reason entry in docs/todo/. Tests of Bladestan's own compiler output (the PHP it generates for PHPStan) have no counterpart here; list them in the README as not ported.