Larastan
Larastan stats
- Downloads
- 25.8M
- Stars
- 4,830
- Open Issues
- 72
- Forks
- 365
Larastan - Discover bugs in your code without running it. A phpstan/phpstan wrapper for Laravel
Larastan: Enhance Your Laravel Code Quality
Larastan is a powerful tool developed by Can Vural and Nuno Maduro, designed to improve code quality in Laravel applications by leveraging PHPStan, a popular PHP static analysis tool. It aims to detect potential errors in your code before you even run tests, effectively enhancing productivity and maintaining high code standards.
Key Features:
- Static Typing for Laravel: Integrates static typing into Laravel, supporting most of Laravel's dynamic features while ensuring code reliability.
- Early Bug Detection: Identifies bugs and issues early in the development process, saving time and reducing potential technical debt.
- Ease of Setup: Can be easily integrated into any Laravel project (version 9.0 and above) with just a few commands.
Installation and Usage:
-
Install via Composer:
composer require nunomaduro/larastan:^2.0 --devFor Laravel package analysis, installation of
orchestra/testbenchmight be necessary. -
Configuration: Create a
phpstan.neonorphpstan.neon.distin your project root with the necessary configurations:includes:- ./vendor/nunomaduro/larastan/extension.neonparameters:paths:- app/level: 5 # Level 9 is the most strict -
Analyse Your Code: Run PHPStan to analyze your project's code:
./vendor/bin/phpstan analyseUse the
--memory-limitoption if you encounter memory issues:./vendor/bin/phpstan analyse --memory-limit=2G
Advanced Configuration:
- Ignoring Errors: Specific errors can be ignored directly in the code or via the configuration file using regex patterns.
- Baseline File: For legacy projects, generate a baseline file to exclude existing errors, allowing you to enforce stricter rules for new code.
- Custom Rules and PHPDoc Types: Extend PHPStan with Laravel-specific rules and custom PHPDoc types to tailor the analysis to your needs.
Getting Involved:
Contributions are welcome, and the contribution guidelines can be found in the project's repository. Keep up with updates and community discussions via the official Twitter accounts and GitHub.
Larastan is an essential tool for any developer looking to maintain high standards in their Laravel applications, ensuring robust and error-free code.
Software engineer at @laravel — working on Laravel, Forge, and Vapor. Created @pestphp, @laravel-zero, collision, @openai-php, php insights, termwind, etc.