TomasVotruba / bladestan

PHPStan analysis for Blade templates

Home Page:https://tomasvotruba.com/blog/introducing-bladestan-phpstan-analysis-of-blade-templates/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bladestan

Static analysis for Blade templates in Laravel projects.

Install

composer require tomasvotruba/bladestan --dev

Configure

Configure paths to your Blade views, unless you use the default resources/views directory:

parameters:
    bladestan:
        template_paths:
            # default
            - resources/views

If you run PHPStan with its extension installer, Bladestan will just work, if not you need to include it in the phpstan.neon configuration file:

includes:
    - ./vendor/tomasvotruba/bladestan/config/extension.neon

Features

Custom Error Formatter

We provide custom PHPStan error formatter to better display the template errors:

  • clickable template file path link to the error in blade template
 ------ -----------------------------------------------------------
  Line   app/Http/Controllers/PostCodexController.php
 ------ -----------------------------------------------------------
  20     Call to an undefined method App\Entity\Post::getConten().
         rendered in: post_codex.blade.php:15
 ------ -----------------------------------------------------------

How to use custom error formatter?

vendor/bin/phpstan analyze --error-format=blade

Credits

About

PHPStan analysis for Blade templates

https://tomasvotruba.com/blog/introducing-bladestan-phpstan-analysis-of-blade-templates/

License:MIT License


Languages

Language:PHP 93.2%Language:Blade 6.8%