This package is maintained by @alies-dev and is open to new contributors. If you're passionate about Laravel internals and static analysis, consider joining the effort.
Areas where help is especially welcome:
- Full support for custom Model Query Builders
- Option to rely on Model
@propertydeclarations only - Remove
barryvdh/laravel-ide-helperdependency for more accurate attribute types - Support
.sqlmigration files for attribute discovery
A Psalm plugin that provides static analysis and type support for Laravel. Catch type-related bugs early — without writing a single test.
Maintained versions:
| Laravel Psalm Plugin | PHP | Laravel | Psalm |
|---|---|---|---|
| 4.x (upcoming) | ^8.3 | 12, 13 | 7 |
| 3.x | ^8.2 | 11, 12 | 6, 7 |
| 2.12+ | ^8.0 | 9, 10, 11 | 5, 6 |
(Older versions of Laravel, PHP, and Psalm were supported by version 1.x of the plugin, but they are no longer maintained)
See releases for more details about supported PHP, Laravel and Psalm versions.
composer require --dev psalm/plugin-laravelIf you didn't use Psalm on the project before, you need to create a Psalm config:
./vendor/bin/psalm --init./vendor/bin/psalm-plugin enable psalm/plugin-laravelRun your usual Psalm command:
./vendor/bin/psalmYou can customize Psalm configuration using XML config and/or cli parameters.
Recommendation: use baseline file and increase
errorLevel at least to 4: this way you can catch more issues.
Step by step set errorLevel to 1 and use Psalm and this plugin at full power 🚀.
Under the hood it just runs https://github.com/barryvdh/laravel-ide-helper and feeds the resultant stubs into Psalm, which can read PhpStorm meta stubs.
It also parses any database migrations it can find to try to understand property types in your database models.
Both! It's fine to use both tools at the same project: they use different approaches to analyze code, and thus you can find more bugs! Psalm and PHPStan use almost the same syntax annotations, so you should not have any conflicts.
