New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

calebdw/phpstan-laravel

A PHPStan extension for analysis of Laravel applications and packages.
25,298 37
Install
composer require calebdw/phpstan-laravel
Latest Version:v1.12.0
PHP:^8.3
Laravel:12 · 13
License:MIT
Last Updated:Nov 3, 2026
Links: GitHub  ·  Packagist
Maintainer: calebdw

phpstan-laravel

Teaches PHPStan about Laravel's magic

Latest Version Laravel Compatibility PHP Compatibility Laravel Boost Total Downloads Tests License

Laravel leans on magic: facades, container bindings, dynamic Eloquent properties, method forwarding, macros. A static analyser sees almost none of it on its own, so the parts of your application that carry the most behaviour are the parts it checks least.

This PHPStan extension closes that gap. It boots your application during analysis and combines that with stubs, reflection extensions and schema scanning, so PHPStan can reason about your models, relations, collections, configuration and views.

$user = User::query()->firstOrFail();   // App\User

$user->email;                           // string
$user->emial;                           // Access to an undefined property
$user->accounts;                        // App\AccountCollection<int, App\Account>

User::query()->pluck('name');           // Collection<int, string>
$user->accounts()->pluck('name');       // Collection<int, string>
User::all()->groupBy('email');          // Collection<string, Collection<int, App\User>>

config('auth.defaults.guard');          // string|null
Config::string('auth.defaults.guard');  // string

User::create(['emial' => '...']);       // Property 'emial' does not exist

None of it comes from annotations you write, and it ships rules for the mistakes Laravel will happily let you make at runtime. It works at every PHPStan level, on applications and on packages.

Documentation

To get started, take a look at the official documentation: installation, configuration, every rule, every option and identifier, and the guide for moving over from Larastan.

Contributing

Contributions are welcome: see CONTRIBUTING.md.

Acknowledgments

This package began as a fork of larastan/larastan, created by Can Vural and Nuno Maduro and improved by many contributors over the years. It would not exist without their work.

License

Open-sourced software licensed under the MIT license.

Related Packages

larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan exte...

88,817,496 6,549
mfn/phpstan-lost-in-translation

Helps find missing translation strings in Laravel applications

8,401 1
prettyyellowdog/lumenstan

Lumenstan - Discover bugs in your code without running it. A phpstan/phpstan wra...

184 0
tomasvotruba/bladestan

PHPStan rule for static analysis of Blade templates

1,070,227 375

Version History

Version Released PHP Laravel License
v1.12.0 ^8.3 ^12.67.0 || ^13.38.0 MIT
v1.11.1 ^8.3 ^12.67.0 || ^13.38.0 MIT
v1.11.0 ^8.3 ^12.67.0 || ^13.38.0 MIT
v1.10.0 ^8.3 ^12.67.0 || ^13.26.1 MIT
v1.9.5 ^8.3 ^12.67.0 || ^13.26.1 MIT