MacBook Pro affichant un éditeur de code

Install xdebug3 with Phpstorm on MacOs

For this example, we will use the Docker installation as well as the Symfony 5 setup described in another article: Article Docker, Symfony 5

Creating an alias for the IP used

On MacOS, it is necessary to create an alias for the IP we use. It is common to use the IP:

10.254.254.254

The command is as follows:

sudo ifconfig lo0 alias 10.254.254.254

If you want it on every restart of the computer, thanks to @ralphschindler on GitHub, this is very simple to do by following his article https://gist.github.com/ralphschindler/535dc5916ccbd06f53c1b0ee5a868c93

Beware, the configuration of xdebug in his article concerns version 2.

The command is as follows

sudo curl -o /Library/LaunchDaemons/com.ralphschindler.docker_10254_alias.plist https://gist.githubusercontent.com/ralphschindler/535dc5916ccbd06f53c1b0ee5a868c93/raw/com.ralphschindler.docker_10254_alias.plist

Creating the xdebug configuration file

With the arrival of version 3 of xdebug, many configuration keys have been renamed.

In the docker -> php-fpm folder, create a xdebug.ini file

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.discover_client_host=off
xdebug.client_host=10.254.254.254
xdebug.client_port=9005
xdebug.idekey=PHPSTORM
xdebug.max_nesting_level=1500

In the Dockerfile in the same folder, add the following command

RUN export XDEBUG_SESSION-PHPSTORM

Configuration of Phpstorm

Create a new server:

And create a new PHP remote debug with this server, indicating the key “PHPSTORM”

Once this is done, you have to go into the xdebug configuration and change the port to 9005 instead of 9000

Browser configuration

On Firefox install the add-on xdebug helper.

Once this is done, indicate that you are using PHPSTORM in the plugin configuration

Firefox

Leave a comment