Two Laravel devs that won't disappear on you. Finally! Hire Joel and Aaron from No Compromises.

Larastan

nunomaduro/larastan image

Larastan stats

Downloads
25.8M
Stars
4,830
Open Issues
72
Forks
365

View on GitHub →

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:

  1. Install via Composer:

    composer require nunomaduro/larastan:^2.0 --dev

    For Laravel package analysis, installation of orchestra/testbench might be necessary.

  2. Configuration: Create a phpstan.neon or phpstan.neon.dist in your project root with the necessary configurations:

    includes:
    - ./vendor/nunomaduro/larastan/extension.neon
     
    parameters:
    paths:
    - app/
    level: 5 # Level 9 is the most strict
  3. Analyse Your Code: Run PHPStan to analyze your project's code:

    ./vendor/bin/phpstan analyse

    Use the --memory-limit option 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.

nunomaduro photo

Software engineer at @laravel — working on Laravel, Forge, and Vapor. Created @pestphp, @laravel-zero, collision, @openai-php, php insights, termwind, etc.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Nunomaduro Larastan Related Articles

Larastan v1.0 Released image

Larastan v1.0 Released

Read article
PestPHP Released as Open-Source image

PestPHP Released as Open-Source

Read article
DreamzTech logo

DreamzTech

Hire 6-10+ Yrs. experienced skilled Laravel Developers from DreamzTech. We ensure NDA protected, 100% quality delivery. Contact Us & Discuss Your Need.

DreamzTech
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Honeybadger logo

Honeybadger

Simple developer-focused application monitoring for Laravel. Error tracking, log management, uptime monitoring, status pages, and more!

Honeybadger
Celebian logo

Celebian

Celebian is a social media marketing agency specializing in helping their clients go viral on TikTok. Whether you're looking to reach a bigger audience or gain more Tiktok followers, likes, and views, they've got you covered.

Celebian
CodeKudu logo

CodeKudu

Stand-ups, Retrospectives, and 360° Feedback for the entire team. 50% off with code LARAVELNEWS.

CodeKudu