- How do I install Bladestan for Laravel Blade static analysis?
- Run `composer require tomasvotruba/bladestan --dev` to add it as a development dependency. If using PHPStan’s extension installer, Bladestan auto-configures. Otherwise, include `./vendor/tomasvotruba/bladestan/config/extension.neon` in your `phpstan.neon` file.
- Does Bladestan work with Laravel 12 and Livewire 4?
- Yes, Bladestan supports Laravel 10–12 and Livewire 3.3–4.0. It also handles dynamic components, Livewire attributes, and non-HTML mail templates. Check the [GitHub](https://github.com/bladestan/bladestan) for version-specific updates.
- What types of Blade errors does Bladestan detect?
- Bladestan catches undefined methods, missing variables, syntax issues, and template rendering errors. It also flags potential runtime exceptions like undefined directives or invalid component usage. The custom error formatter pinpoints exact template lines and rendered paths.
- Can I customize Bladestan’s rules for my project?
- Yes, Bladestan extends PHPStan’s rule engine, so you can override or extend its rules via `phpstan.neon`. Start with conservative settings to avoid false positives, then tighten rules incrementally. Use `ignoreErrors` for known edge cases.
- How do I integrate Bladestan into CI/CD pipelines?
- Run `vendor/bin/phpstan analyze --error-format=blade` in your CI. Decide whether to fail builds on critical errors or treat them as warnings. Cache PHPStan results to speed up CI runs. Example: `phpstan analyze --level=5 --error-format=blade` for strict checks.
- Will Bladestan slow down my Laravel application in production?
- No, Bladestan is a static analysis tool with no runtime overhead. It runs during development or CI, not in production. Use PHPStan’s result caching to minimize analysis time in pipelines.
- How do I exclude certain Blade templates from analysis?
- Add `excludeFiles` or `excludePaths` to your `phpstan.neon` to skip non-critical templates. For example: `excludePaths: ['resources/views/legacy/*']`. Focus on high-impact templates like forms, emails, or critical views first.
- What if Bladestan produces false positives for dynamic Blade logic?
- False positives often occur with dynamic method calls or complex logic. Start with a permissive rule set, then enable stricter checks gradually. Use `ignoreErrors` in `phpstan.neon` to suppress known false positives, like `ignoreErrors: ['#Call to undefined method.*#']`.
- Does Bladestan support Symfony components or non-HTML templates?
- Yes, Bladestan analyzes non-HTML templates (e.g., mail views) and supports Symfony components when used in Blade. For Livewire or Symfony integrations, test with representative templates early and monitor updates for compatibility with newer versions.
- What are the alternatives to Bladestan for Blade static analysis?
- Alternatives include custom PHPStan rules or tools like `laravel-blade-analyzer` (older, less maintained). Bladestan stands out for its Laravel-specific focus, Livewire support, and integration with PHPStan’s ecosystem. If your team doesn’t use PHPStan, consider starting with it for broader static analysis benefits.