PhpStorm - SonarLint Plugin
Daniel Opitz
01 Dec 2019
I’m sure you’ve heard of phpstan, psalm, and the PhpStorm Php Inspections (EA Extended) plugin. Maybe you’re already using one of these great tools to scan your codebase for issues and possible bugs. But this time I want to show you another very cool static code analyzer for PHP:
The SonarLint Plugin for PhpStorm.
SonarLint is an IDE extension that helps you detect and fix quality issues as you write code. Like a spell checker, SonarLint squiggles flaws so they can be fixed before committing code. You can get it directly from the IntelliJ IDEA Plugin Repository, and it will then detect new bugs and quality issues as you code (PHP, Java, Kotlin, Ruby, JavaScript and Python).
If your project is analyzed on SonarQube or on SonarCloud, SonarLint can connect to the server to retrieve the appropriate quality profiles and settings for that project.
Installation
- Open PhpStorm > File > Settings > Plugins
- Type “SonarLint” to search for the plugin
- Click: Install
- Restart PhpStorm
Configuration
- Open the
SonarLint
tab (to the right of theVersion Control
tab) - Open the
Report
tab - Click the
Configure SonarLint
button - Open the
File Exclusions
tab and exclude thevendor/
directory of your project.
Usage
To start the code analysis…
- Open the
SonarLint
>Report
tab - Click the
Analyze all Project files
button
As soon as the scan is completed, you should see the result of the code inspection: