Use SonarQube to debug PHP code

Installing and using SonarQube Community Edition to debug your PHP code its fairly easy. But in involves a number of steps, spread among few docs, so I decided to write myself this little memo to compile one single step-by-step flow for this.

I assume that I’ll be using SonarQube to check quality of my PHP project (though SonarQube supports dozens of languages). This project is stored locally and directly accessible (this article does not cover dealing with repositories or embedding SonarQube into your release pipelines).

I am using XAMPP to host my PHP projects locally, but that part doesn’t play any significant role here.

Perform installation


  1. Install Java 17 JDK or JRE on your computer
  2. Download SonarQube Community Edition in newest available version
  3. Unzip this file to i.e. C:\XAMPP\sonarqube

Now start your SonarQube server instance:


Note that it will take some time (it took 10+ seconds and an intense fan work to get SonarCube up and running on i9 / 32 GB).

If your instance fails to start, check your logs to find the cause.

Start a project

  1. Log in to http://localhost:9000 using System Administrator credentials (admin \ admin)
  2. Change password to something complex upon your first visit.
  3. Select Create new projectManually
  4. Give your project a Project key and a Display name and select Set up
  5. Select Locally in the How do you want to analyze your repository? view
  6. Click Generate, write down your project’s key:
"test": sqp_75339ea7f6f7af449ff6c08c28703a6f08b5bffd
  1. Click Continue
  2. Click Other (for JS, TS, Go, Python, PHP, …)
  3. Click Windows


Install SonarScanner


  1. Download SonarScanner in Windows 64-bit version
  2. Unzip downloaded files to a directory of your source, i.e.: C:\XAMPP\sonarscanner
  3. Double-click This PC on your desktop while holding Left Alt key pressed to go to Settings → System → About
  4. Click Advanced system settings and go to Advanced → Environment Variables…
  5. Double-click line with Path item and click New
  6. Copy-paste your SonarScanner’s path (i.e.: C:\XAMPP\sonarscanner) and confirm with Enter
  7. If you had any console window open, close it and re-open it, so it gets newest Path settings
  8. Edit the C:\XAMPP\sonarscanner\conf\ file, to see if points to http://localhost:9000
  9. Open command line and execute sonar-scanner -h to see, if your SonarScanner instance is reachable

Configure your project


  1. Go to your project’s root folder and create file there
  2. Provide content similar to this:
  1. If there’s any need, you may configure project’s version, source location and encoding as well:

Go to your project’s root directory (i.e. where file is stored) and execute scanner by providing your project’s token (which you generated previously):

sonar-scanner -Dsonar.login=sqp_75339ea7f6f7af449ff6c08c28703a6f08b5bffd

Go back to your SonarQube instance (in the browser), wait a couple of seconds and see the results of your project’s analysis:


Leave a Reply