Php Debugger in NuSphere PhpED

Every program no matter how well written can have bugs or other defects – there’s no exception to this rule, including in your PHP scripts or any other software program that you develop. Debugging is the process of finding the bugs so they can be fixed and the PHP Debugger is the best tool for helping you find the bugs fast and eliminate them from your PHP programs. You can setup remote debugging in PhpED with the help of debug PHP Settings Wizard and DBG Wizard. For information about supported platforms and how to install PHP Debugger modules please check debugging PHP on various platforms page.

How to debug a PHP script

There are many techniques used for PHP debugging, varying from desperate PHP code inspection to angry keyboard slamming. A less extreme and more useful approach would be to use print statements and logging embedded in your PHP code, printing out variable values throughout various stages of the program execution.

This approach works well in general, however suffers from several drawbacks, for example:

  • It requires significant additional coding effort, which ironically can introduce even more bugs into your php script
  • Debugging of PHP with print statements is a highly repetitive process – it’s impossible for a developer to lock onto a problematic region of code while printing everything and everywhere
  • Introduction of so many print statements and conditional can affect the performance of your PHP application.
PhpED’s PHP Debugger provides a powerful and easy way to simplify PHP debugging because it gives you complete visibility and control over the execution of PHP scripts and doesn’t require that you make any changes to your PHP code. With PhpED’s PHP Debugger you can:

PHP Debugger

Special Feature

How to use PhpED’s PHP Debugger

PhpED’s PHP Debugger will let you step through your php code, control the execution flow, see the current values of all variables in the script as well as content of the arrays and classes at each stage or even assign different values to the variables on the fly and do all of it without making any changes to php application. This brief tutorial will help you to learn how to use PhpED’s PHP Debugger.

Step through lines of php code


PhpED’s PHP Debugger lets you step through the execution of a php scripts, line-by-line, just as you would using a conventional software debugger. Using the PhpED Debugger toolbar, you can:

  • Step-In: Execute the next line of php code.
  • Step-Out: Return to the line of php code that called the function you are in.
  • Step-Over: Execute the current line of php code.

Inspect Call-Stack

Single-Stepping through a PHP script in PHP Debugger

The Call Stack window displays the function calls that brought you to the current script location. The top of the Call Stack window lists the last function called by your script. Below this is the listing for the previously called function. The listing continues, with the first function called in your script located at the bottom of the list. The Call Stack window also shows the names of member functions (or methods). Each member function is prefixed with the name of the class that defines the function.

Inspect any variable or class in PHP


PhpED’s PHP Debugger three ways to see the values of the variables or the members of the PHP class.

  • The value of the variable is shown when the cursor is hovered over the variable in PHP code
  • The values of the Local variables and classes are displayed in Locals tab of PhpED debugger
  • The values of the Global variables and classes are displayed in Globals tab of PhpED debugger
  • Variables and classes added to the Watch tab of PhpED debugger and displayed there
Debugger Watch tab in PHP Debugger

Assign a different value to PHP variables in the script


The PhpED PHP Debugger will let you assign a different value to any PHP variable. This feature allows you test your fix before you change the actual PHP code in the script.

Changing value of a PHP variable in PHP Debugger

Set/toggle break points to interrupt php script execution


PhpED allows you to easily set and toggle breakpoints anywhere in your PHP code. The lines of code highlighted in blue represent breakpoints. The line in red shows the PHP script current state. You can set/toggle breakpoints from a toolbar, by typing the “F5″ key, or by clicking on the red dot to the left of the line of code.
Learn more about PHP Debugger Breakpoints here

Debugger Breakpoints in PHP Debugger

Call PHP function on the fly and inspect the results


Using Immediate tab of PhpED debugger you can call any php function on the fly in the middle of the execution of your PHP script. Simply type in the function call in the window and press Enter. The functionality of Immediate tab is illustrated here:

Debugger Immediate tab in PHP Debugger

Trigger PHP Debugger on Errors and Exceptions

You can PhpED automatically switch to debug mode when there are PHP errors or exceptions occuer in the code. To set this behavior and other settings for PHP Debugger or Profiler use Tools->Settings->Run and Debug

PHP Debugger Settings

In this tutorial you learned about the many features of the PHP Debugger and how to use them to quickly find and eliminate bugs from your PHP scripts. You can watch a live demonstration of using the PHP debugger and advanced remote PHP debugging from our video tutorial library. Additional technical information is available on the NuSphere Forum. Download a free trial of our PHP Debugger today!

Nusphere PhpED 7.0

Download Download PhpED Trial V

دیدگاه خود را بنویسید