Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>Real Time PHP Static Analysis For PHP and LaravelNew to Visual Studio Code? Get it now.
Real Time PHP Static Analysis For PHP and Laravel

Real Time PHP Static Analysis For PHP and Laravel

ddarkonen

|
4,338 installs
| (1) | Free
Real Time Static analysis support for PHP and Laravel with PhpStan and LaraStan
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VSCode PhpStan README

A vscode extension for phpstan and larastan.

A modified version of the great work of breeze2

I made made my own version this extension because I need a plug and play extension that works with live type checking and only required conf is to have installed phpstan and larastan to work with Laravel projects.

Features

Type checking while you write auto lint your php code, or use the command:

  • PhpStan: Lint this file
  • PhpStan: Lint this folder

Requirements

  • php >= 7.1
  • phpstan >= 0.11 If in Laravel project just:
  • larastan 0.7.11

If using Laravel: Install larastan

composer require --dev nunomaduro/larastan

Create phpstan.neon on working directory and add the following

  includes:
      - ./vendor/nunomaduro/larastan/extension.neon
  parameters:
      paths:
          - app
      level: 5
      ignoreErrors:
      checkMissingIterableValueType: false

If not

composer require --dev phpstan/phpstan

or

composer require global phpstan/phpstan

Extension Settings

For example:

This extension contributes the following settings:

  • phpstan.level: rule levels 0-7, default max
  • phpstan.noProgress: no progress output, default true
  • phpstan.memoryLimit: memory limit, default 512M
  • phpstan.configuration: path of configuration
  • phpstan.autoloadFile: path of autoload file, default vendor/autoload or null
  • phpstan.liveErrorTracking: Enable or disable live error tracking, default true
  • phpstan.debounce: Debounce time when live error tracking enabled, default true
  • phpstan.tmpPath: path to temporary folder, default system tmp folder

Known Issues

  • May need more memory when linting too many files

Improving performance

Debounce option

Depending on the speed of your computer and the size of your project you could reduce debounce to 1000 or 500ms so you will have faster type checking.

Create a RAM DISK

For live type checking as this extension does not use a server we need to save to temporary files in order to allow phpstan to analyze current working file, so its reading and writing file every few seconds, in order to improve a little:

You can create a ram disk to enhance disk writing files speed Example for MacOs

diskutil erasevolume HFS+ 'RAMDisk' `hdiutil attach -nobrowse -nomount ram://256000`

This will create a Volume on Volumes\RAMDisk Then change on the phpstan.tmpPath to point to the created RAMDisk

You could also modify the phpstan.neon file to include inside parameters, this will make all cache generated by phpstan to be on the very fast RAMDisk:

If working with phpstan in RAM you would need to increase RAMDisk to > 4Gb because of its caching
tmpDir: /Volumes/RAMDisk

This disk is not persistent so you should create the RAMDisk on every restart (google tells you how to automatize this)

Release Notes

1.0.0

  • Initial release of vscode-phpstan-larastan with live type checking

1.0.1

  • Automatic detection of autoload and phpstan.neon for Laravel

1.0.2

  • Compile extension with webpack size reduce 100 times

1.0.3

  • Update readme and add gif animation

1.0.4

  • Fix typos. thanks to Michael Blair

Attributions

Icon by: icon-monk Original work: (https://github.com/breeze2/vscode-phpstan)[https://github.com/breeze2/vscode-phpstan]

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft