In this shot, we’ll learn to debug our Laravel application.
We can equate Larastan to PHPStan, except in this instance, Larastan actually works in a PHP framework.
Larastan can be seen as a tool for code analysis that helps find errors in our code blocks. It finds errors that can only be found at runtime.
Larastan is a good tool to debug our application’s errors before deployment.
We’ll run code analysis on our Laravel application using the steps below.
larastanas a development dependency.
composer require nunomaduro/larastan --dev
phpstan.neon.distfile in the root directory:
includes: - ./vendor/nunomaduro/larastan/extension.neon parameters: paths: - app # The level 9 is the highest level level: 5 ignoreErrors: - '#Unsafe usage of new static#' excludePaths: - ./*/*/FileToBeExcluded.php checkMissingIterableValueType: false
Note: Please refer to PHPStan documentation for more options.
If we get the
Allowed memory size exhausted error, we should use
--memory-limit to fix it:
./vendor/bin/phpstan analyse --memory-limit=2G
View all Courses