Debugging
How to check logs and configure Xdebug
Log files
Log files are automatically created in the project folder in the subfolder "log".
access.log (nginx access log)
error.log (nginx error log)
php-fpm-error.log (php-fpm error log)
Follow logs with
Xdebug
To setup Xdebug in your local environment you need to do the following (some parts of the following are mainly for PhpStorm and chrome, and might need to be changed if using a different IDE):
Adding and volume-linking the .ini file
For Xdebug to run properly it needs to have an xdebug.ini file. In your Docker environment this needs to be mounted into the docker container. To do this, you need to create an xdebug.ini file and place it in the root of the project. The .ini file should contain the following:
For using different IDEs the xdebug.idekey
might need to be changed.
Once this file is in place, you want to have it mounted into the php-fpm Docker container on container start. This can be accomplished by making sure the following is present in your docker-compose.yml
Configuring PhpStorm
You now need to configure PhpStorm to use Xdebug. To do this, go to Run -> Edit configurations...
. Now click the +
and select Php Remote Debug
. You may give this configuration a name, but leaving it blank works as well. Once that is in place you need to configure the mapping towards your local webserver.
Go to Preferences -> Languages & Frameworks -> PHP -> Servers
, add a new configuration with +
and use the following settings:
In the left column, select your project's www
directory, then in the right column on the same row enter /var/www
.
All that is left now is to add the Xdebug extension to chrome.
Running Xdebug
With the browser extension in place, all you need to do is add a breakpoint to your php code, go to Run -> Run
in PhpStorm and select your debug configuration, and finally select Debug
in your browser extension and reload the page you want to debug.
Xdebug and Postman
If you wish to debug a request sent by Postman, all you need to do is add XDEBUG_SESSION_START=PHPSTORM
as a key-value pair to the request body and start the debug config as you would when debugging via Chrome.
Last updated
Was this helpful?