PhpED’s Debugger lets you step through the execution of a php scripts, line-by-line, just as you would using a conventional software debugger.
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:• Step through lines of php code
2.Inspect any variable or class in PHP
3.Assign a different value to PHP variables in the script
4.Set break points to interrupt php script execution
5.Make break points act based on various conditions
6.Call a PHP function on the fly and inspect the results
7.Support for remote PHP debugging
8.All major server platforms are supported
- Parallel debug sessions
- Just in Time debugging
- Change Execution point on the fly
- Global breakpoints with conditions
- Secure debugging: IP security and traffic encryption
- Advanced php profiler
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.
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.
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). After that 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.
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.
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 also 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.
Call PHP function on the fly and inspect the results
First thing to remember is 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:
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
The Evaluate/Modify window displays a non blocking dialog that can be used to evaluate an expression, which is too complex for the simple tool tip hint provided by the debugger and when the use of Watch is unnecessary. If the cursor is placed over a variable in the script, the variable under the cursor will be evaluated automatically and displayed in the dialog. The dialog is not modal so you can continue debugging session w/o closing this dialog.
Remote Debugging with SSH Tunnel
SSH Tunnels can be used for the communications with PHP Debugger on remote server. In addition using SSH Tunnels on SSH equiped remote server you can getrid of the headache of dealing with Firewalls and Routers.
Remote and Local debugging of PHP CLI scripts
Debugging is also available for Command Line Interface PHP scripts. To set up Remote Debugging of CLI script you need to select Remote Server as a Run Target in project properties and specify Terminal account to login to the remote server as well as Php executable to be used for CLI run
This is of course not neccassary for local debugging of PHP CLI scripts. To run or debug PHP scripts select CLI (Console) from Run menu (HTTP is for regular Web Server scripts debugging).
Locus Academy has more than a decade experience in delivering the training/staffing on Php Debugger for corporates across the globe. The participants for the training/staffing on Php Debugger are extremely satisfied and are able to implement the learnings in their on going projects.