Use this skill to set up PHPStan (via Larastan) in a Laravel project. Trigger when the user asks to add static analysis, set up PHPStan, install Larastan, create phpstan.neon, or generate a PHPStan baseline. Covers: Larastan installation, phpstan.neon configuration, level 6 analysis, baseline generation, Laravel-specific rules, and Composer scripts. Do not use for runtime debugging, test writing, or code formatting.
This skill sets up PHPStan static analysis in a Laravel project using Larastan — the official PHPStan wrapper that understands Laravel's magic (facades, models, relations, containers, etc.).
Install Larastan and the PHPStan extension installer as dev dependencies:
composer config allow-plugins.phpstan/extension-installer true
composer require --dev larastan/larastan phpstan/extension-installer mrpunyapal/peststan
Allow the extension-installer plugin first — Composer blocks plugins not listed in allow-plugins and the install will fail without this step.
extension-installer automatically registers PHPStan extensions (including Larastan) — no need to manually add includes in phpstan.neon.
peststan adds PHPStan rules specific to Pest tests (e.g. enforcing correct usage of , , datasets).
it()expect()Create phpstan.neon in the project root:
使用 Arthas 的 watch/trace 获取 EagleEye traceId / 获取请求的 traceId