Sarah shouldnt be alone tonight

Sarah was home alone, and she knew that something was wrong. She could feel it in her bones. The storm outside was raging, and the wind was howling like a pack of wolves. The power went out, and…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Debugging your PHP application inside a Docker environment using Xdebug

Once our environment is ready, let’s install Xdebug in our PHP container by adding those lines to our PHP-FPM Dockerfile.

Now, let’s configure Xdebug, and this can be done by creating a xdebug.ini file in the conf.d/ configuration folder.

The idekey is a token that our host machine use to reconnect to the container, we’ll use this key when we configure our IDE.

The final step is to configure whatever we use to write and debug our PHP code, the configuration is almost the same for all editors and here we’ll see how to do it for Sublime Text and PhpStorm.

After that, we need to map our host application folder to the application folder in the container. Here is an example of my configuration:

Remember the idekey we configured earlier in the xdebug.ini file, we’ll set it here with the port also like this.

The Tools > Xdebug > Settings - Default menu show the plugin configuration with a description of every parameter.

To start debugging we use the Tools > Xdebug > Start Debugging menu, we can set breakpoints to check the state of our application environment in a given time of the execution. The menu to navigate during the debugging can be found by a right-click when editing a PHP file.

In case of using PhpStorm, we need only to configure the Xdebug port using the Preferences menu and look for xdebug using the search input.

And to map our host application folder to the application folder in the container we look for the preference using servers filter, and we add a new server by clicking on the + sign and we set whatever we want as a server name, the Host will be the default host for our local application, and the most important part here is to map the application local and container folders.

Finally we set the debugger by Run > Edit Configurations and we add a debugger by clicking on the + sign again and choose PHP Remote Debug, let’s give it a name and choose the server we create earlier, in the ide key we need to use the same key we used in Xdebug configuration sublime.xdebug.

To start debugging we click on the phone icon on the top right.

And this is all, happy debugging ;)

Add a comment

Related posts:

Commonly used terms in Apache Kafka

Here are some commonly used terms in Apache Kafka:. “Commonly used terms in Apache Kafka” is published by Lipsa Biswas.

Balloon arch

Decorating for a graduation party doesn’t have to be hard. With a few simple ideas, you can create a festive and fun space for your graduate and their friends. Here are five balloon decoration ideas…