PhpDev.App
psalm/psalm-plugin-laravel

psalm/psalm-plugin-laravel

Stars: 263

Forks: 59

Pull Requests: 234

Issues: 113

Watchers: 10

Last Updated: 2023-07-14 00:05:16

A Psalm plugin for Laravel

License: MIT License

Languages: PHP, Gherkin, Shell

Psalm plugin for Laravel

Packagist version Packagist downloads Type coverage Tests Tests

Overview

This Psalm plugin brings static analysis and type support to projects using Laravel. Our goal is to find as many type-related bugs as possible, therefore increasing developer productivity and application health. Find bugs without the overhead of writing tests!

Screenshot

Versions & Dependencies

Laravel Psalm Plugin PHP Laravel Psalm
2.x ^8.0 8, 9, 10 4, 5
1.x ^7.1 5, 6, 7, 8 3, 4

See releases for more details about supported PHP, Laravel and Psalm versions.

Quickstart

Step 1: Install

composer require --dev psalm/plugin-laravel

Step 2: Configure

If you didn't use Psalm on the project before, you need to create a Psalm config:

./vendor/bin/psalm --init

Step 3: enable the plugin:

./vendor/bin/psalm-plugin enable psalm/plugin-laravel

Step 4: Run πŸš€

Run your usual Psalm command:

./vendor/bin/psalm

You can customize Psalm configuration using XML config and/or cli parameters.

Recommendation: use baseline file and increase errorLevel at least to 4: this way you can catch more issues. Step by step set errorLevel to 1 and use Psalm and this plugin at full power πŸš€.

How it works

Under the hood it just runs https://github.com/barryvdh/laravel-ide-helper and feeds the resultant stubs into Psalm, which can read PhpStorm meta stubs.

It also parses any database migrations it can find to try to understand property types in your database models.

Psalm-Laravel-Plugin or Larastan?

Both! It's fine to use both tools at the same project: they use different approaches to analyze code, and thus you can find more bugs! Psalm and PHPStan use almost same the syntax annotations, so you should not have any conflicts.

OPEN ISSUES

See all

RELEASES

See all