Skip to main content
Back to packages
6,430 GitHub stars

nunomaduro/larastan

View on GitHub

Description

Adds code analysis to Laravel improving developer productivity and code quality

Create a phpstan.neon or phpstan.neon.dist file in the root of your application. It might look like this:

includes:
- vendor/larastan/larastan/extension.neon
- vendor/nesbot/carbon/extension.neon
 
parameters:
 
paths:
- app/
 
# Level 10 is the highest level
level: 5
 
# ignoreErrors:
# - '#PHPDoc tag @var#'
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php

For all available options, please take a look at the PHPStan documentation: https://phpstan.org/config-reference

You may start analyzing your code using the phpstan console command:

./vendor/bin/phpstan analyse

If you are getting the error Allowed memory size exhausted, then you can use the --memory-limit option fix the problem:

./vendor/bin/phpstan analyse --memory-limit=2G

Related Content on Laravel Daily

Video

Recent Courses on Laravel Daily

Next.js Basics for Laravel Developers

11 lessons
58 min

Laravel 13 Eloquent: Expert Level

41 lessons
1 h 34 min

Queues in Laravel 13

18 lessons
1 h 12 min read