Larastan
I use Larastan as a way to bring static analysis into a Laravel project without ignoring Eloquent, facades, and the dynamic parts of the framework. It does not replace tests or review, but it can catch type errors, incorrect return values, and small problems that would otherwise appear only when the application is running.
Larastan is one of those tools that does not look exciting at first, but can do a lot for the long-term health of a project. It will not make an admin screen faster, it will not add a visible feature, and a client will probably never notice it directly. Still, it can change how confidently a developer can move through a Laravel application.
Laravel is a dynamic framework. Eloquent models, facades, collections, the service container, and magic methods are convenient, but ordinary static analysis can struggle with them. Larastan builds on PHPStan and adds Laravel-specific knowledge. That allows it to find problems that plain PHPStan might miss or report too generally.
Why static analysis matters
In a small application, tests and manual review may feel sufficient. But the longer a project lives, the more small inconsistencies appear. A method returns something different than expected. A collection contains a different type of object. A relationship is named differently than a developer remembers. A nullable value is passed into a place that never expected null.
Larastan helps catch these issues earlier. It does not wait for the bug to happen in production or for a test to accidentally cover the exact path. It scans the code and points to places where types, return values, or method calls do not make sense. It is not a replacement for tests. It is another layer of feedback that covers a different kind of risk.
Laravel without false confidence
The biggest value of Larastan is that it does not ask developers to ignore how Laravel actually works. Generic PHP analysis can be either too weak or too noisy in frameworks with dynamic behavior. Larastan understands models, facades, the service container, and other Laravel concepts better, so its feedback is usually more useful.
That does not mean installing it solves everything. In an older application, the first run may report a lot of issues. Some will be real bugs. Others will be places where the code simply lacks precise types or documentation. The goal is not necessarily to reach the strictest level on day one. The first benefit is seeing where the codebase is unclear.
Increasing strictness gradually
I would introduce Larastan gradually. In an existing project, turning on the strictest settings immediately and spending a week fighting thousands of messages is rarely a good plan. It is better to choose a level the team can handle, fix the most valuable findings, and then raise the bar over time. Static analysis should support development, not become a new source of frustration.
A good rule is that new code should not add new problems. Older debt can be reduced step by step, while the pipeline prevents it from growing. Combined with PHPDoc, collection generics, more precise return types, and clearer service boundaries, Larastan starts showing value quickly.
Where it fits in the process
Larastan makes the most sense in CI next to tests, Pint, Rector, and other checks. Tests verify behavior, Pint checks style, Rector handles mechanical refactoring, and Larastan looks at type and structural consistency. Each tool protects a different part of the project. Together, they give the developer more confidence that a change is not only green locally, but also fits the wider codebase.
For AI-assisted development, that matters even more. An agent can generate code that looks convincing while still using the wrong type or calling a method that does not exist. Larastan can often catch that faster than a person reading a diff. Human review and judgment are still necessary, but static analysis reduces the space for quiet mistakes that would otherwise travel too far.
hub Related tools
Explore similar tools
A random selection of tools from the same category.
Pest PHP
Pest PHP is a modern testing framework for PHP with a simple and readable syntax. It is not only a nicer way to write tests, but a tool that lowers the friction of testing regularly and fits naturally into the Laravel ecosystem. It helps most when tests are a normal part of development, not a separate chore at the end.
Laravel Pint
Laravel Pint solves one quiet but important problem: the team no longer has to keep discussing PHP code formatting. It is built on top of PHP-CS-Fixer, ships with sensible Laravel defaults, and works well both for local fixes and CI checks. Its biggest value appears when code style stops being a code review topic.
Laravel Boost
Laravel Boost starts to make sense when an AI agent should stop answering in general terms and work with a real Laravel application instead. It helps the agent understand package versions, routes, database schema, configuration, and documentation, so suggestions are less detached from the project. It is still only support for the developer, but in a larger codebase it can remove a lot of manual lookup work.
add_circle Missing a tool?
Suggest a tool for the list
If you could not find a useful tool here, send me its name and URL. I will review it and consider adding it to the public catalog.