Basic Laravel Blade Template Support#100
Merged
AJenbo merged 5 commits intoAJenbo:mainfrom May 2, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #100 +/- ##
==========================================
- Coverage 86.66% 86.60% -0.07%
==========================================
Files 164 168 +4
Lines 106572 107553 +981
==========================================
+ Hits 92360 93145 +785
- Misses 14212 14408 +196 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Introduce `src/blade` module to handle Blade template compilation into virtual PHP. - `BladeSourceMap`: Provides `blade_to_php` and `php_to_blade` coordinate translation to accurately map LSP positions. - `preprocessor`: A state-machine parser that translates Blade directives and echo statements into PHP equivalents while maintaining strict 1:1 line mappings. - `directives`: Matcher and translator for Blade control structures and view directives.
- Wire the Blade preprocessor into file open and change events. - Intercept LSP requests (hover, completion, definitions, diagnostics, semantics tokens, inlay hints) and translate incoming Blade coordinates to Virtual PHP coordinates. - Route the translated requests to the existing Mago/PHPantom static analysis engine. - Translate the output coordinates back to Blade before responding to the editor. - Exclude Blade specific dummy elements from diagnostic reporting.
- Add tests to ensure go-to-definition, reference finding, and syntax error resilience work correctly within `.blade.php` files. - Add test fixtures simulating real-world Blade files and syntax edges (e.g. multi-line directives, mixed HTML/PHP).
AJenbo
reviewed
May 2, 2026
Comment on lines
-5
to
-7
| //! | ||
| //! # Philosophy | ||
| //! |
Owner
There was a problem hiding this comment.
Some of the changes here are a bit destructive
various adjusments
Owner
|
Thanks, this is a big step on the roadmap! |
Owner
|
I added highlighting and compleation on dynamic types which made it feel a bit more well rounded. Other then that really nice work here I think this makes a really solid first level Blade support. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces initial support for Laravel Blade templates (.blade.php) in PHPantom. It allows developers to enjoy features like Go-to-Definition,
Completion, Hover, and Diagnostics directly inside Blade files by leveraging a Virtual PHP preprocessing strategy.
The implementation is highly modular and designed with Zero-Overhead for non-Laravel developers, as the Blade logic is only triggered for files ending in
.blade.php.
Architecture & Data Flow
To reuse the existing Mago/PHPantom static analysis engine without modifying its core, we use a "Virtual PHP" approach. Here is how a request (e.g.,
"Completion") flows through the system:
@if($user->isAdmin())becomesif($user->isAdmin()):Virtual PHP.
into original Blade coordinates.
Key Features
@if,@foreach), and Layout Directives (@extends,@include).diagnostics.
Core Library Refactoring & Justification
This PR introduces Blade template support for diagnostics and coordinate translation. To achieve this, several core library files were refactored. These
changes were necessary to move from a "PHP-only" mindset to a "multi-language/virtual file" architecture.
a Source Map.
allows the engine to detect if a file is Blade and automatically apply the correct coordinate transformation, ensuring red lines appear in the correct
place in the editor.
both the "Analyze" command and the live editor experience.
more complex project structures.
down to PHP, ensuring a seamless experience across different file types.
Quality Assurance (Local Validation)