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

Psalm Laravel Package

vimeo/psalm

Psalm is a powerful PHP static analysis tool that finds type errors and bugs before runtime. Install via Composer, configure for your codebase, and run it locally or try the live demo at psalm.dev. Docs and integrations available for teams and CI.

View on GitHub
Deep Wiki
Context7

Psalm is a static analysis tool that helps you find bugs, type issues, and unsafe patterns in PHP codebases before they hit production. It integrates into existing projects and CI pipelines, providing actionable diagnostics and improving code quality over time.

Explore it via the live demo on psalm.dev, or follow the official docs and setup guide to get started.

  • Detects type mismatches, undefined variables, and other common PHP errors
  • Supports gradual adoption with configurable strictness levels
  • Provides rich diagnostics and reporting for large codebases
  • Includes extensive documentation and community support channels
Frequently asked questions about Psalm
How do I install Psalm for a Laravel project?
Run `composer require vimeo/psalm --dev` to install Psalm as a development dependency. Initialize its configuration with `./vendor/bin/psalm --init`, which generates a `psalm.json` file. Adjust paths in this file to match your Laravel project’s structure (e.g., `src`, `app`, `database`).
Does Psalm work with Laravel’s Eloquent ORM?
Psalm supports Eloquent but may flag dynamic queries (e.g., `Model::where()`) as type errors. Mitigate this by using custom stubs like `vimeo/psalm-plugin-laravel` or adding ignore rules in `psalm.json` for specific methods. Pre-built stubs help reduce false positives.
Can Psalm analyze Blade templates (.blade.php files)?
Psalm ignores Blade files by default. To analyze them, explicitly include Blade paths in `psalm.json` under `files` or use `exclude_patterns` to filter out non-PHP files. However, dynamic Blade content (e.g., `@php`) may still require stubs or manual tuning.
What Laravel versions does Psalm support?
Psalm works with Laravel 5.8+ but integrates best with Laravel 9+ (PHP 8.1+), where native type hints reduce noise. For older Laravel versions (e.g., PHP 7.4), use docblock annotations (`@var`, `@return`) and expect more manual configuration to avoid false positives.
How do I integrate Psalm into GitHub Actions for Laravel?
Add a step to your workflow after `composer install` to run Psalm with strict checks. Example: `./vendor/bin/psalm --no-cache --threads=4`. Use exit codes (0=clean, 2=errors) to block merges. Cache results between runs to improve performance for large codebases.
Will Psalm break my legacy Laravel codebase?
Psalm is configurable to avoid breaking changes. Start with `--init` and gradually increase strictness. Use `psalm-refactor` for safe automated fixes (e.g., namespace changes) and `psalter` with `--safe-types` to preview risky changes before applying them.
How do I handle false positives in Laravel-specific code?
False positives often occur with dynamic Laravel features (e.g., `Facade::class`, magic methods). Create custom stubs for third-party packages or use `stub_files` in `psalm.json` to point to community stubs like `laravel-stubs`. Ignore specific errors with `ignore_errors` or `@psalm-suppress` annotations.
Can Psalm improve performance for large Laravel apps?
Psalm’s analysis is CPU-intensive. For large apps, use `--threads=4` (or higher) and `--diff` in CI to analyze only changed files. Cache results between runs with tools like `psalm --cache-results` or integrate with GitHub Actions caching to reduce runtime.
Are there alternatives to Psalm for Laravel static analysis?
Yes, alternatives include PHPStan (more strict but slower) and PhpMD (less type-focused). Psalm stands out for its balance of performance and Laravel integration, especially with plugins like `vimeo/psalm-plugin-laravel`. Choose based on your need for type safety vs. runtime speed.
How do I refactor Laravel code safely using Psalm?
Use `psalm-refactor` for bulk changes (e.g., renaming classes, moving namespaces) and `psalter` to preview fixes. For Laravel, ensure stubs are up-to-date to avoid errors in dynamic code. Test refactored code locally before applying changes to the full project.
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