Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Larastan Laravel Package

nunomaduro/larastan

Larastan is a PHPStan extension for Laravel that analyzes your app to catch bugs early. It boots the container to resolve dynamic types, supports Laravel’s “magic,” and improves code quality with stronger static typing.

View on GitHub
Deep Wiki
Context7

Larastan is a PHPStan extension for Laravel that brings powerful code analysis to your app. By booting Laravel’s container, it can infer types that are only known at runtime—helping you catch entire classes of bugs before tests run.

Use it to improve type safety, developer productivity, and overall code quality while still supporting Laravel’s “magic”.

  • Deep Laravel support (container-aware type resolution)
  • Finds bugs and dead code early via strict analysis
  • Improves typing across models, facades, and helpers
  • Works with modern stacks: PHP 8.2+ and recent Laravel versions
Frequently asked questions about Larastan
How does Larastan differ from regular PHPStan for Laravel?
Larastan extends PHPStan to boot Laravel’s container, resolving types that are only known at runtime (e.g., dynamic facades, Eloquent models). This lets it catch bugs like undefined methods or incorrect return types in Laravel-specific code that regular PHPStan would miss.
Can I use Larastan with Laravel 9 or older versions?
Yes, but you’ll need Larastan v1.x for Laravel <9.0 and v2.x for Laravel 9.0+. For Laravel 11.16+, use v3.0+. Check the [supported versions table](https://github.com/larastan/larastan#supported-laravel-versions) for exact mappings.
Will Larastan break my existing code due to strict typing?
Not necessarily. Start with `level: 1` in `phpstan.neon` to catch only critical errors, then gradually increase the level. Use `@phpstan-ignore-line` or `ignoreErrors` to suppress false positives while refactoring.
How do I configure Larastan to analyze migrations and schema dumps?
Enable `enableMigrationCache` in `phpstan.neon` to speed up analysis, or disable `disableSchemaScan` if you don’t need schema validation. For large projects, consider `--memory-limit=2G` to avoid crashes during migration scans.
Does Larastan work with Laravel’s dynamic properties (e.g., `$request->input()`)?
Yes, but you may need to configure `errors-to-ignore.md` to handle edge cases like `HigherOrderCollectionProxy` or dynamic facades. Larastan is designed to support Laravel’s “magic” while still enforcing type safety.
Can I integrate Larastan into GitHub Actions or CI/CD pipelines?
Absolutely. Add `./vendor/bin/phpstan analyse` to your CI workflow (e.g., GitHub Actions) with `level: 5` for strict checks. Use `fail-on-error: true` to block merges with new type violations.
How does Larastan handle legacy code without PHPDoc types?
Use baseline files (`--generate-baseline`) to record current errors, then fix them incrementally. For untyped legacy code, start with `level: 1` and gradually increase strictness while adding PHPDoc annotations.
Will Larastan slow down my development workflow?
Initial analysis may take time for large codebases, but Larastan is designed for development-time checks. Enable `enableMigrationCache` in CI to speed up repeated runs, and consider running it in parallel with other tools like Pint.
Does Larastan replace Laravel IDE Helper or PHP-CS-Fixer?
No. Larastan focuses on static type analysis, while Laravel IDE Helper generates PHPDoc stubs for IDEs. Use both: Larastan catches bugs, and IDE Helper improves autocompletion. PHP-CS-Fixer handles coding standards separately.
How do I suppress false positives for specific classes or methods?
Add `@phpstan-ignore-line` or `@phpstan-ignore-next-line` inline, or configure `ignoreErrors` in `phpstan.neon` with class/method patterns. For complex cases, maintain an `errors-to-ignore.md` file to document known exceptions.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport