Installing Java Development Kit (JDK)
PhpStorm requires a Java runtime environment (JRE) to operate. On CentOS, install OpenJDK 11 or higher using the package manager:
sudo yum install openjdk-11-jdk
Verify the installation with:
java -version
This ensures PhpStorm has the necessary Java environment to run.
Downloading and Installing PhpStorm
Download the Linux version of PhpStorm from JetBrains’ official website. Extract the archive to a directory (e.g., /opt/phpstorm) using:
sudo tar -xvzf PhpStorm-*.tar.gz -C /opt/phpstorm
Optionally, add the PhpStorm binary directory to your system’s PATH by editing ~/.bashrc (or ~/.profile) and appending:
export PATH=$PATH:/opt/phpstorm/bin
Reload the configuration with source ~/.bashrc. Start PhpStorm by running /opt/phpstorm/bin/phpstorm.sh.
Configuring PHP Interpreter
To enable PhpStorm to analyze PHP code, set the PHP interpreter:
/usr/bin/php) and click OK.Setting Up Code Inspection Tools
PhpStorm supports multiple tools for enforcing code standards and static analysis. A common choice is PHP Code Sniffer (phpcs):
composer global require "squizlabs/php_codesniffer=*"
~/.composer/vendor/bin/phpcs).Running Manual Code Inspection
To analyze your entire project or selected files:
Enabling Real-Time Code Checking
PhpStorm provides real-time feedback as you type. To ensure this is active:
Optional: Configuring Other Tools
For deeper static analysis, integrate tools like PHPStan or Psalm:
composer global require phpstan/phpstan), then configure the executable path in Settings > Languages & Frameworks > PHP > Code Sniffer.composer global require phpstan/psalm), then follow similar steps to add it to PhpStorm.