Qodana 2021.2 Help

Qodana for PHP

official project

Qodana PHP is based on PhpStorm and provides static analysis for PHP projects. It brings all the smarts from PhpStorm, which help you:

  • detect anomalous code and probable bugs

  • eliminate dead code

  • highlight spelling problems

  • improve overall code structure

  • introduce coding best practices

Try it now

Analyze a project locally

To start, pull the image from Docker Hub (only necessary to get the latest version):

docker pull jetbrains/qodana-php

If you use PHP Composer, add the following step before running the analysis:

docker run --rm -v <source-directory>:/app composer:latest install

If you need to change the language level, add the following into <source-directory>/.idea/php.xml:

<?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="PhpProjectSharedConfiguration" php_language_level="<desired level>" /> </project>

Run the analysis locally:

docker run --rm -it -v <source-directory>/:/data/project/ \ -p 8080:8080 jetbrains/qodana-php --show-report

with source-directory pointing to the root of your project.

This command will run the analysis on your source code and start the web server to provide a convenient view of the results. Open http://localhost:8080 in your browser to examine the found problems and performed checks. Here you can also reconfigure the analysis. See the User interface overview for details. When done, you can stop the web server by pressing Ctrl-C in the Docker console.

Next steps

Last modified: 14 October 2021