Skip to content

Larastan

Clio Brichaut edited this page Jan 14, 2023 · 1 revision

What is it?

"Larastan focuses on finding errors in your code. It catches whole classes of bugs even before you write tests for the code." [source]

"Larastan is a phpstan wrapper for Laravel." [source]

Setup

  1. Install the package with ./vendor/bin/sail composer require nunomaduro/larastan --dev (in wsl terminal) or composer require nunomaduro/larastan --dev (in the php container).

  2. Create the /app/app/phpstan.neon file containing the paths to include in the analysis, and the analysis' strictness (level=0-9):

includes:
  - ./vendor/nunomaduro/larastan/extension.neon

parameters:
  paths:
    - app/
    - database/factories
    - database/seeders
    - routes
    - tests
  level: 9

Usage

Execute the analysis with ./vendor/bin/phpstan analyze (in the php container).

The output should look like this:

image

Clone this wiki locally