canvural/phpstan-blade-rule
A PHPStan rule for Laravel Blade templates that brings static analysis to your views. Catch undefined variables, type mismatches, and other errors in .blade.php files before runtime by analyzing compiled templates with PHPStan.
@include scoping fix materially affects that sequencing: teams that tried this rule earlier and hit false positives on partials now have a reason to re-evaluate.@include means views that use include-heavy composition (layouts, component partials, shared fragments) become analyzable. Supports a decision to consolidate or refactor partials rather than rewrite them as Livewire/Inertia components on the assumption that Blade is un-analyzable.Consider it when:
@include/@each composition, non-trivial variable passing).@include not receiving expected data.0.x version line: expect occasional false positives and pin versions in composer.json.Look elsewhere or wait when:
0.x line can introduce behavioral changes in minor releases.@include/@component patterns may require per-file ignores, which some teams treat as a code smell. Do a trial run on the messiest views before committing.The v0.4 fix is a maintenance-grade improvement, not a new capability — it removes a known source of @include false positives. It changes the evaluation calculus only for teams that previously trialed and abandoned the rule for that reason.
For executives: A small, low-cost quality gate for the view layer of our Laravel app — the one part of the codebase standard static analysis can't see. It catches template bugs (missing or mistyped variables) before customers do. Cost is a dev-only dependency and a CI step; there's no runtime footprint and no vendor lock-in. Treat it as a reliability improvement, not a platform bet, and expect to pin the version given its early (0.x) maturity.
For engineering: canvural/phpstan-blade-rule extends PHPStan to Blade templates, catching undefined variables and type mismatches in views. v0.4 fixes @include variable scoping — the main known false-positive source — so include-heavy partials are now worth analyzing. Add as a require-dev, pin the version, generate a baseline, and gate new code rather than retrofitting the whole view tree at once. Expect some iteration on ignores for exotic directive usage; budget a short spike on our most complex views to size that.
How can I help you explore Laravel packages today?