psalm/plugin-laravel
Psalm plugin for Laravel that adds deep framework-aware static analysis plus taint-based security scanning. Detects SQL injection, XSS, SSRF, shell injection, file traversal, and open redirects by tracking user input flows across functions and services.
Laravel static analysis with built-in security scanning.
The only free tool that combines deep Laravel type analysis with taint-based vulnerability detection. Catches SQL injection, XSS, SSRF, shell injection, file traversal, and open redirects — without running your code.
Already using Larastan? psalm-plugin-laravel complements it with security analysis that PHPStan cannot provide.

Plugin ships Laravel-specific taint stubs that track user input from source to sink across your entire codebase. Unlike pattern-matching tools, Psalm follows dataflow across function boundaries — catching vulnerabilities that simpler scanners miss.
// psalm-plugin-laravel catches this:
Route::get('/search', function (Request $request) {
$query = $request->input('q');
DB::statement("SELECT * FROM users WHERE name = '$query'");
// TaintedSql: user input flows directly to the SQL query
});
Taint analysis also works across helper functions, service classes, and any number of call layers:
// Cross-function taint flow — pattern-matching tools miss this:
function getUserQuery(Request $request): string {
return "SELECT * FROM users WHERE name = '" . $request->input('name') . "'";
}
Route::get('/users', function (Request $request) {
DB::statement(getUserQuery($request));
// Psalm catches this: taint flows Request -> getUserQuery() -> DB::statement()
});
| Vulnerability | OWASP | Examples |
|---|---|---|
| SQL Injection | A03:2021 | DB::statement(), DB::unprepared(), raw query methods |
| Shell Injection | A03:2021 | Process::run(), Process::command() |
| XSS | A03:2021 | Response::make() with unescaped content |
| SSRF | A10:2021 | Http::get(), Http::post() with user-controlled URLs |
| File Traversal | A01:2021 | Storage::get(), File::delete() with user-controlled paths |
| Open Redirect | A01:2021 | redirect(), Redirect::to() with user-controlled URLs |
| Crypto misuse | A02:2021 | Tracks encryption/hashing taint escape and unescape |
Security scanning runs automatically alongside type analysis — no extra configuration needed.
| Tool | Laravel-aware types | Taint analysis | Free |
|---|---|---|---|
| psalm-plugin-laravel | Yes | Yes (dataflow) | Yes |
| Larastan | Yes | No (PHPStan can't) | Yes |
| Enlightn Pro | Partial | No (rule-based) | $99+/project |
| SonarQube | Generic PHP | Yes (generic) | Paid editions only |
| Semgrep | Pro tier only | Pattern-based | Limited free tier |
| Snyk Code | Generic | Yes (generic) | Freemium |
Maintained versions:
| Laravel Psalm Plugin | PHP | Laravel | Psalm | Status |
|---|---|---|---|---|
| 4.x | ^8.2 | 12, 13 | 7 | Stable |
| 3.x | ^8.2 | 11, 12 | 6 | Stable |
| 2.12+ | ^8.0 | 9, 10, 11 | 5, 6 | Legacy |
(Older versions of Laravel, PHP, and Psalm were supported by version 1.x of the plugin, but they are no longer maintained)
See releases for more details about supported PHP, Laravel and Psalm versions. Upgrading from v3? See the v3 → v4 upgrade guide.
composer require --dev psalm/plugin-laravel
If you didn't use Psalm on the project before, you need to create a Psalm config:
./vendor/bin/psalm --init
./vendor/bin/psalm-plugin enable psalm/plugin-laravel
Run your usual Psalm command:
./vendor/bin/psalm
Security taint analysis runs automatically as part of the standard analysis in Psalm 7. No extra flags are needed.
On an existing codebase, the first run will likely report many issues. A baseline file lets you suppress all current issues and focus only on new code:
./vendor/bin/psalm --set-baseline=psalm-baseline.xml
From here, gradually increase errorLevel (start at 4, work toward 1) and shrink the baseline over time.
You can customize Psalm configuration using XML config and/or cli parameters.
See docs/config.md for all configuration options.
The plugin emits custom issues beyond Psalm's built-in checks:
env() called outside config/ directoryargument() references undefined command argumentoption() references undefined command optionview() references a non-existent Blade template (opt-in)__() or trans() references an undefined translation key (opt-in)Model::make() used instead of new Model()Under the hood it reads Laravel's native @method annotations on facade classes and generates alias stubs based on Illuminate\Foundation\AliasLoader (including aliases from your config/app.php and package discovery). It also ships hand-crafted stubs for taint analysis and special cases.
It also parses SQL schema dumps (php artisan schema:dump) and PHP migration files to infer column names and types in your database models.
Use both. They solve different problems:
model-property validation, view-string checks, and 17+ custom rules.Psalm and PHPStan use almost the same annotation syntax, so they work side by side without conflicts.
Larastan checks your types. We check your security. Use both.
Maintained by @alies-dev. PRs and issues welcome — first-time contributors too. There are contributing docs that may help you (and your agents) with contributions.
Areas where help is especially needed:
How can I help you explore Laravel packages today?