PHPackages                             larastan/larastan - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. larastan/larastan

ActivePhpstan-extension[Testing &amp; Quality](/categories/testing)

larastan/larastan
=================

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

v3.9.3(2mo ago)6.4k43.5M—7.5%492[79 issues](https://github.com/larastan/larastan/issues)[51 PRs](https://github.com/larastan/larastan/pulls)20MITPHPPHP ^8.2CI passing

Since Jul 17Pushed 3w ago48 watchersCompare

[ Source](https://github.com/larastan/larastan)[ Packagist](https://packagist.org/packages/larastan/larastan)[ GitHub Sponsors](https://github.com/canvural)[ RSS](/packages/larastan-larastan/feed)WikiDiscussions 3.x Synced 1mo ago

READMEChangelog (10)Dependencies (34)Versions (194)Used By (20)

 [![Larastan Logo](https://raw.githubusercontent.com/larastan/larastan/master/docs/logo.png)](https://raw.githubusercontent.com/larastan/larastan/master/docs/logo.png)

 [![Larastan Example](https://raw.githubusercontent.com/larastan/larastan/master/docs/example.png)](https://raw.githubusercontent.com/larastan/larastan/master/docs/example.png)

 [![Build Status](https://github.com/larastan/larastan/actions/workflows/tests.yml/badge.svg)](https://github.com/larastan/larastan/actions) [![Total Downloads](https://camo.githubusercontent.com/0e45f58e487efdf13d0bb7e8aa70999813dda6fad7b13fd961d9cf91ecb854fc/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617374616e2f6c6172617374616e2f642f746f74616c2e737667)](https://packagist.org/packages/larastan/larastan/stats) [![Latest Version](https://camo.githubusercontent.com/d898fbc71ea12015382eeeb61315cfd40bde28461523d4fbf9e6a53547ecfc97/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617374616e2f6c6172617374616e2f762f737461626c652e737667)](https://packagist.org/packages/larastan/larastan) [![License](https://camo.githubusercontent.com/257e82070c253d9b48251a07e757627e59abb7cb9d95453179b19354b048d2dd/68747470733a2f2f706f7365722e707567782e6f72672f6c6172617374616e2f6c6172617374616e2f6c6963656e73652e737667)](https://github.com/larastan/larastan/blob/master/LICENSE.md)

---

⚗️ About Larastan
-----------------

[](#️-about-larastan)

Larastan was created by [Can Vural](https://github.com/canvural) and [Nuno Maduro](https://github.com/nunomaduro), got artwork designed by [@Caneco](http://github.com/caneco), is maintained by [Can Vural](https://github.com/canvural), [Nuno Maduro](https://github.com/nunomaduro) and [Viktor Szépe](https://github.com/szepeviktor), and is a [PHPStan](https://phpstan.org/) extension for Laravel. Larastan focuses on **finding errors in your code**. It catches whole classes of bugs even **before you write tests** for the code.

- Adds static typing to Laravel to improve developer productivity and **code quality**
- Supports most of [Laravel](https://laravel.com)'s **beautiful magic**
- Discovers bugs in your code

> While by definition, "static analysis" doesn't load any of your application's code. Larastan boots your application's container, so it can resolve types that are only possible to compute at runtime. That's why we use the term "code analysis" instead of "static analysis".

### Supported Laravel versions

[](#supported-laravel-versions)

Laravel VersionLarastan Version&lt; 91.x&gt; 9.0 &amp;&amp; &gt;= 11.162.x11.16+3.0+Sponsors
--------

[](#sponsors)

[![Blackfire.io](assets/blackfire-logo.png)](https://blackfire.io/docs/introduction?utm_source=larastan&utm_medium=github_readme&utm_campaign=logo)

✨ Getting Started In 3 Steps
----------------------------

[](#-getting-started-in-3-steps)

> **Requires:**

- **[PHP 8.2+](https://php.net/releases/)**
- **[Laravel 11.15+](https://github.com/laravel/laravel)**

**1**: First, you may use [Composer](https://getcomposer.org) to install Larastan as a development dependency into your Laravel project:

```
composer require --dev "larastan/larastan:^3.0"
```

> Using Larastan for analysing Laravel packages? You may need to install `orchestra/testbench`.

**2**: Then, create a `phpstan.neon` or `phpstan.neon.dist` file in the root of your application. It might look like this:

```
includes:
    - vendor/larastan/larastan/extension.neon
    - vendor/nesbot/carbon/extension.neon

parameters:

    paths:
        - app/

    # Level 10 is the highest level
    level: 5

#    ignoreErrors:
#        - '#PHPDoc tag @var#'
#
#    excludePaths:
#        - ./*/*/FileToBeExcluded.php

```

For all available options, please take a look at the PHPStan documentation: ****

**3**: Finally, you may start analyzing your code using the phpstan console command:

```
./vendor/bin/phpstan analyse
```

If you are getting the error `Allowed memory size exhausted`, then you can use the `--memory-limit` option fix the problem:

```
./vendor/bin/phpstan analyse --memory-limit=2G
```

Ignoring errors
---------------

[](#ignoring-errors)

Ignoring a specific error can be done either with a php comment or in the configuration file:

```
// @phpstan-ignore-next-line
$test->badMethod();

$test->badMethod(); // @phpstan-ignore-line
```

When ignoring errors in PHPStan's configuration file, they are ignored by writing a regex based on error messages:

```
parameters:
    ignoreErrors:
        - '#Call to an undefined method .*badMethod\(\)#'
```

### Baseline file

[](#baseline-file)

In older codebases it might be hard to spend the time fixing all the code to pass a high PHPStan Level.

To get around this a baseline file can be generated. The baseline file will create a configuration file with all of the current errors, so new code can be written following a higher standard than the old code. ([PHPStan Docs](https://phpstan.org/user-guide/baseline))

```
./vendor/bin/phpstan analyse --generate-baseline
```

Rules
-----

[](#rules)

A list of configurable rules specific to Laravel can be found [here](docs/rules.md).

Features
--------

[](#features)

A list of Larastan features can be found [here](docs/features.md).

Custom PHPDoc types
-------------------

[](#custom-phpdoc-types)

A list of PHPDoc types specific to Larastan can be found [here](docs/custom-types.md).

Custom PHPStan config parameters
--------------------------------

[](#custom-phpstan-config-parameters)

A list of custom config parameters that you can use in your PHPStan config file can be found [here](docs/custom-config-parameters.md).

Errors To Ignore
----------------

[](#errors-to-ignore)

Some parts of Laravel are currently too magical for Larastan/PHPStan to understand. We listed common [errors to ignore](docs/errors-to-ignore.md), add them as needed

👊🏻 Contributing
---------------

[](#-contributing)

Thank you for considering contributing to Larastan. All the contribution guidelines are mentioned [here](CONTRIBUTING.md).

📖 License
---------

[](#-license)

Larastan is an open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

85

—

ExcellentBetter than 100% of packages

Maintenance89

Actively maintained with recent releases

Popularity83

Widely adopted with strong download metrics

Community66

Healthy contributor diversity

Maturity94

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~15 days

Total

185

Last Release

60d ago

Major Versions

v2.10.0 → v3.2.02025-03-14

v2.11.0 → v3.4.02025-04-22

v2.11.1 → v3.4.12025-06-09

v2.11.2 → v3.5.02025-06-19

2.x-dev → v3.6.02025-07-11

PHP version history (5 changes)v0.1.0PHP ^7.1.3

v0.5.1PHP ^7.2

v0.6.9PHP ^7.2 || ^8.0

2.0.0PHP ^8.0.2

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/d2f83986d283a52780c9a1e81cfc84d37cdd2e7596ccc5a748f02f2cf69d5336?d=identicon)[canvural](/maintainers/canvural)

---

Top Contributors

[![canvural](https://avatars.githubusercontent.com/u/1574232?v=4)](https://github.com/canvural "canvural (711 commits)")[![nunomaduro](https://avatars.githubusercontent.com/u/5457236?v=4)](https://github.com/nunomaduro "nunomaduro (460 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (182 commits)")[![calebdw](https://avatars.githubusercontent.com/u/4176520?v=4)](https://github.com/calebdw "calebdw (61 commits)")[![Daanra](https://avatars.githubusercontent.com/u/6588838?v=4)](https://github.com/Daanra "Daanra (35 commits)")[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (24 commits)")[![spawnia](https://avatars.githubusercontent.com/u/12158000?v=4)](https://github.com/spawnia "spawnia (23 commits)")[![mad-briller](https://avatars.githubusercontent.com/u/28307684?v=4)](https://github.com/mad-briller "mad-briller (17 commits)")[![CyberiaResurrection](https://avatars.githubusercontent.com/u/9083866?v=4)](https://github.com/CyberiaResurrection "CyberiaResurrection (14 commits)")[![ramonrietdijk](https://avatars.githubusercontent.com/u/85165272?v=4)](https://github.com/ramonrietdijk "ramonrietdijk (12 commits)")[![kylekatarnls](https://avatars.githubusercontent.com/u/5966783?v=4)](https://github.com/kylekatarnls "kylekatarnls (12 commits)")[![mvdnbrk](https://avatars.githubusercontent.com/u/802681?v=4)](https://github.com/mvdnbrk "mvdnbrk (11 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (9 commits)")[![erikgaal](https://avatars.githubusercontent.com/u/1234268?v=4)](https://github.com/erikgaal "erikgaal (8 commits)")[![johanvanhelden](https://avatars.githubusercontent.com/u/19389981?v=4)](https://github.com/johanvanhelden "johanvanhelden (8 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (8 commits)")[![0xb4lint](https://avatars.githubusercontent.com/u/3747631?v=4)](https://github.com/0xb4lint "0xb4lint (7 commits)")[![crissi](https://avatars.githubusercontent.com/u/3076578?v=4)](https://github.com/crissi "crissi (7 commits)")[![BertvanHoekelen](https://avatars.githubusercontent.com/u/7521173?v=4)](https://github.com/BertvanHoekelen "BertvanHoekelen (7 commits)")[![mr-feek](https://avatars.githubusercontent.com/u/5747667?v=4)](https://github.com/mr-feek "mr-feek (7 commits)")

---

Tags

code-analysislaravelphpphpstanphpPHPStanlaravelstatic analysispackagecode analysiscode analyselarastan

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/larastan-larastan/health.svg)

```
[![Health](https://phpackages.com/badges/larastan-larastan/health.svg)](https://phpackages.com/packages/larastan-larastan)
```

###  Alternatives

[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

1484.6k3](/packages/calebdw-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M532](/packages/laravel-passport)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
