Skip to content

How to debug this application in PhpStorm #1

@dzschille

Description

@dzschille

My steps how i could debug the app:

First consideration: in phpdocker/php-fpm/php-ini-overrides.ini i set xdebug.remote_port to 9000 which is xdebugs default.
An other option would be to change the port in PhpStorms debug configuration.

How to start the app:

composer install

docker-compose up -d
  • Open the app in the browser: http://localhost:8074/
  • With a browser extension enable debugging.
  • In PhpStorm open the project.
  • In PhpStorm click "Start Listening for PHP debug connections".
  • Reload the page in the browser.
  • Now PhpStorm reacts and tells you that you should set up the server. If there is no reaction, check if your local IP as seen from the webserver container:
        ## open console in webserver and view your host IP
        docker-compose exec webserver /bin/sh -c "/sbin/ip route|awk '/default/ { print \$3 }'"

Now take this IP and set it in docker-compose.yml as value XDEBUG_CONFIG. Then you have to stop your docker containers and start them with docker-compose up -d again. You have to use "up" because "start" does not handle the config change.

  • Set the server name according to the one you have set as env var in docker-compose.yml. Als set the path mapping. The project root to /application is sufficient:
    debugging-1-configure-server
  • Now you can debug the code:
    debugging-2-stepping
  • You can also set break points:
    debugging-3-break-point
  • Here a screenshot where you can change the xdebug port, if you want to listen to another one than 9000:
    debugging-4-phpstorm-debug-config

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions