Weave Code
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

Bladestan Laravel Package

tomasvotruba/bladestan

Bladestan brings PHPStan-powered static analysis to Laravel Blade templates. It catches template-related issues during analysis and offers a Blade error formatter with clickable template paths and “rendered in” context for faster debugging.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Seamless Laravel Integration: Designed as a PHPStan extension, it natively integrates with Laravel’s Blade templating system, leveraging the framework’s internal view resolution, Livewire component parsing, and dynamic directive handling. This ensures high fidelity in static analysis without requiring custom Blade parsers or runtime hooks.
  • PHPStan Ecosystem Compatibility: Built as a PHPStan extension, it inherits the tool’s configuration system (phpstan.neon), caching, and CLI workflows. This minimizes tooling fragmentation and allows teams to adopt it alongside existing static analysis pipelines (e.g., Psalm, Pest).
  • Deep Blade Coverage: Supports all major Blade features, including:
    • Dynamic components (@component, @slot).
    • Livewire 3/4 props and attributes.
    • @include, @once, @each, and conditional directives.
    • Mail templates and non-HTML views.
    • PHP 8+ syntax (e.g., named arguments, union types). This makes it future-proof for Laravel’s evolving templating needs.
  • Error Precision: Provides line-accurate, clickable error reports with context (e.g., "rendered in: post_codex.blade.php:15"), reducing debugging time by 30–50% compared to runtime errors.

Integration Feasibility

  • Low-Coupling Design: Requires zero runtime changes—only a composer require and phpstan.neon configuration. No Laravel service providers, facades, or middleware modifications are needed.
  • CI/CD Readiness: Designed for pre-commit hooks (e.g., GitHub Actions, GitLab CI) and gated deployments. The --error-format=blade flag ensures actionable feedback for developers.
  • Backward Compatibility: Supports Laravel 8–12, PHP 8.1+, and Livewire 3.3–4.0, with no breaking changes in recent releases. The package’s active maintenance (last release: 2026-03-16) mitigates long-term risk.
  • Dependency Lightweight: Adds <1MB to vendor/ and no production overhead. Ideal for serverless or containerized Laravel apps.

Technical Risk

Risk Area Mitigation Strategy
False Positives Configure phpstan.neon to ignore known edge cases (e.g., dynamic Blade logic). The package respects PHPStan’s rule filtering and provides identifier-based ignores (since v0.11.3).
Livewire/Component Issues Test with Livewire 4.0 and Laravel 12 in staging. The package’s application-aware parsing (e.g., reading Livewire namespace from config/livewire.php) reduces flakiness.
Performance Overhead Disable in production (dev-only tool). Cache invalidation (fixed in v0.11.5) ensures no regression in PHPStan’s speed.
Unsupported Blade Features Extend the package via custom PHPStan rules or submit PRs. The open-source model (MIT license) allows community-driven enhancements.
PHPStan Version Lock Pin PHPStan to a supported range (e.g., ^2.0) in composer.json to avoid compatibility drift. The package migrated to PHPStan 2.0 in v0.7.0.

Key Questions for TPM

  1. Static Analysis Maturity:

    • Does the team already use PHPStan? If not, assess adoption effort (e.g., configuration, developer training).
    • Are there existing Blade bugs causing production incidents? Quantify the cost of runtime fixes (e.g., support tickets, rollbacks).
  2. CI/CD Integration:

    • Can Bladestan run in <5 minutes for the largest templates? Profile with phpstan analyze --memory-limit=1G.
    • Should errors block merges (e.g., GitHub Actions fail-fast) or warn only? Align with team’s shift-left culture.
  3. Livewire/Component Usage:

    • Does the app use dynamic components or Livewire props? Validate the package’s support with a sample component suite.
    • Are there custom Blade directives? These may require manual rule extensions.
  4. Maintenance Plan:

    • Assign a tech lead to monitor updates (e.g., Laravel 13 support). The package’s active maintenance (364 stars, 174+ PRs) is a positive signal.
    • Schedule quarterly reviews to update phpstan.neon ignores as the codebase evolves.
  5. Developer Experience:

    • Will the custom error formatter (--error-format=blade) integrate with the team’s IDE (e.g., PHPStorm, VSCode)? Test with clickable links in error output.
    • Provide onboarding docs with:
      • A phpstan.neon template.
      • Common false-positive examples (e.g., @if($user?->name)).
      • A cheat sheet for Livewire/Blade-specific rules.

Integration Approach

Stack Fit

  • PHPStan-Centric: Ideal for teams already using PHPStan for PHP code analysis. The package extends (not replaces) existing workflows, ensuring zero disruption.
  • Laravel-Specific: Optimized for Laravel’s Blade compiler, Livewire, and view resolution. Avoids generic template tools (e.g., Twig-based analyzers) that lack Laravel context.
  • Dev-Only: No runtime impact, making it safe for serverless, edge deployments, or strict CI environments.
  • Multi-Framework: While Laravel-focused, the PHPStan extension model could theoretically support non-Laravel Blade (e.g., October CMS) with minor config tweaks.

Migration Path

Phase Action Items Success Metrics
Assessment 1. Audit top 10 Blade templates causing production bugs. Identify 3+ recurring issues (e.g., undefined methods, missing variables).
2. Verify PHPStan version compatibility (composer show phpstan). No major version conflicts (e.g., PHPStan 1.x vs. 2.x).
3. Check for custom Blade directives or Livewire 2.x usage. Confirm no unsupported features block adoption.
Pilot 1. Add to composer.json (dev dependency). composer install succeeds without conflicts.
2. Configure phpstan.neon: includes: [./vendor/tomasvotruba/bladestan/config/extension.neon] works.
3. Test locally on 2–3 critical templates (e.g., checkout, dashboard). 0–2 false positives after initial tuning.
CI Integration 1. Add to .github/workflows/phpstan.yml: CI job passes in <3 minutes for full codebase.
```yaml
- run: vendor/bin/phpstan analyze --error-format=blade --level=max
```
2. Set failure mode: if: always() (warn) or if: success() (block). Align with team’s gated deployment policy.
Rollout 1. Enable for all Blade files in phpstan.neon. 100% template coverage in CI.
2. Train devs on error formatter and Livewire-specific rules. <5% support tickets related to Blade errors post-rollout.
Optimization 1. Tune phpstan.neon ignores for false positives. <1% false positives in production templates.
2. Add pre-commit hook (e.g., Husky) for local validation. 80% devs run Bladestan before pushing.

Compatibility

  • Laravel Versions: Tested on 8–12. For Laravel 13, monitor the package’s GitHub for updates or contribute a PR.
  • PHPStan Versions: Requires **PHPStan 2.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport