Tuesday, December 15, 2020

Watch out! XDebug 3 will not work with some older PHPStorm versions

 I lost like half a day till a figure it out why XDebug from my Docker container will not work properly with PHPStorm.

In Preferences > Languages & Frameworks > PHP, add a new CLI Interpreter. Choose the Docker option, and PHPStorm will automatically find the Xdebug image for you.

At the end of this step I would see correct version of PHP, correct version of XDebug but an error message like: Xdebug: [Step Debug] Could not connect to debugging client (tried using xdebug.client_host ..).

It was driving me nuts, the debugger would stop at first line in code and when going to next breakpoint would just idle.

Short term solution: edit dockerfile to install older XDebug version:

# install xdebug
RUN pecl install xdebug-2.6.1
RUN docker-php-ext-enable xdebug

Long term solution: buy a newer PHPStorm version :)