Every software product has bugs because nobody is perfect and every developer commits mistakes.

Therefore all developers need to use debugging tools to fix their code as soon as possible.

XDebug is an excellent debugging extension but it can be used in aw way that is more productive if you use it in conjunction with a IDE like CodeLobster that provides support to debug PHP code using XDebug.

Read this article to learn how to debug PHP code using CodeLobster IDE with XDebug.

Here we call the function power2() in the loop and pass to it the current value of the counter $i, sequentially, from 0 to 9. This method raises the passed value to power 2 and returns each result in a separate line.

Let's open the source project file in the editor and set the breakpoint at the beginning of the file or in the place from which you want to start debugging the script.

Then press F5, the application will be opened in the browser by default and the script execution will stop at the first breakpoint.

Now you can go through each line of code sequentially by pressing the F11 key, or from one breakpoint to another, by repeatedly pressing F5.

The stop points are added and deleted by mouse click to the left of the line number in the editor, or by pressing the F9 key.

And at every moment when the cursor stops we have the opportunity to get full information about the current state of the application, looking to the tabs on the bottom panel of the IDE.

The "Call Stack" tab allows you to trace the entire sequence of function calls up to the current moment, namely, the path that the interpreter passed through our code.

The "Locals" tab reflects the current state of variables in the context of our application. In this example, at any step during debugging you can find out the value of the $i counter, as well as the contents of global and super global variables, such as $_GET, $_POST, $_SERVER, and others.

The "Errors" tab shows the list of errors that occurred, it tells us the type of error, file name and line number, as well as a brief description of the situation, that allows the programmer to quickly orient and fix the bug.

Also useful is the ability to add variables to the watch list, the so-called Watch. Use the context menu for this, right click on the variable and select "Add Watch" or press Alt + Shift + W hotkeys.

Thus, by opening the "Watch" tab, you will be able to observe the changes in the values of several variables at the same time as you go with the debugger through your code.

You can stop the debugging process at any time by pressing Shift + F5.

So, let's sum up

CodeLobster IDE easily integrates with XDebug, the program practically does not require any settings for that and the debugging process is organized predictably and understandably even for a beginner developer.

Setting up XDebug to interact with the IDE, as you could already sure, also does not cause any difficulties.

Now you know the efficient way to speed up the process of finding and fixing errors in your applications and you can avoid cumbersome constructions in your code, like the var_dump() or print_r() functions.