Skip to content

You are viewing the documentation for version 2.x. The latest version is 3.x.

PHPStan

Overview

Run PHPStan across your Laravel app and all Modules using a PHP config file that globs module directories at runtime.

<?php

return [
    'includes' => [
        './phpstan-baseline.php',
    ],
    'parameters' => [
        'level' => 5,
        'paths' => [
            __DIR__ . '/app',
            __DIR__ . '/config',
            ...glob(__DIR__ . '/Modules/*', GLOB_ONLYDIR),
        ],
        'excludePaths' => [
            'analyseAndScan' => [
                ...glob(__DIR__ . '/Modules/*/Tests', GLOB_ONLYDIR),
                ...glob(__DIR__ . '/Modules/*/Database', GLOB_ONLYDIR),
                ...glob(__DIR__ . '/Modules/*/Resources', GLOB_ONLYDIR),
            ],
        ],
        'databaseMigrationsPath' => glob('Modules/*/Database/Migrations', GLOB_ONLYDIR),
        'tmpDir' => 'storage/phpstan',
        'checkOctaneCompatibility' => true,
        'checkModelProperties' => true,
    ],
];

Key points:

  • ...glob(...) dynamically includes all module directories (requires PHP 8.1+).
  • excludePaths skips Tests, Database, and Resources directories.
  • databaseMigrationsPath points PHPStan at module migration directories.

Running PHPStan

./vendor/bin/phpstan analyse -c phpstan.php

Baseline

Generate a baseline to suppress existing issues:

./vendor/bin/phpstan analyse -c phpstan.php --allow-empty-baseline --generate-baseline phpstan-baseline.php
Scroll to top