After initially writing about Larastan back in 2018, we are pleased to see the release of Larastan v1.0 this week, a package to help analyze Laravel application code:
Larastan is a development dependency that adds static analysis to Laravel, improving developer productivity and code quality. At the core, it's a PHPStan wrapper for Laravel and helps you find errors in your code through static analysis. It helps catch bugs before you even write tests for the code:
- Adds static typing to Laravel to improve developer productivity and code quality
- Supports most of Laravel's beautiful magic
- Discovers bugs in your code without running it
You can use Larastan to analyze application code as well as use it to analyze your Laravel packages.
Getting started in your new or existing Laravel project is as easy as installing the package and configuring PHPStan:
1composer require nunomaduro/larastan --with-dependencies --dev23# after setting up a `phpstan.neon` file in the root4# of your project, you can analyze your code:5./vendor/bin/phpstan analyse
You can learn more about this package, get full installation instructions, and view the source code on GitHub. I'd recommend checking out the rules specific to Laravel applications, with configurable options.
- Dynamic method return type extension for
- New rule to check for relation existence in #985
rescuefunction now accepts the
Throwableby @sebdesign in #989
CheckJobDispatchArgumentTypesCompatibleWithClassConstructorRulerule in #991
non-empty-stringtypes in stubs. c5b81cf
- PHPStan 1.0 compatibility in #968