Does php have a debugger?

If you find Xdebug useful, please consider supporting the project.

Xdebug is an extension for PHP, and provides a range of features to improve the PHP development experience.

Step DebuggingA way to step through your code in your IDE or editor while the script is executing.Improvements to PHP's error reportingAn improved var_dump() function, stack traces for Notices, Warnings, Errors and Exceptions to highlight the code path to the errorTracingWrites every function call, with arguments and invocation location to disk. Optionally also includes every variable assignment and return value for each function.ProfilingAllows you, with the help of visualisation tools, to analyse the performance of your PHP application and find bottlenecks. Code Coverage AnalysisTo show which parts of your code base are executed when running unit tests with PHP Unit.

This site and all of its contents are Copyright © 2002-2022 by Derick Rethans.
All rights reserved.

When you start a debugging session, a set of Debugger windows opens below the main editor window. The debugger windows enable you to keep track of variable and expression values as you step through code, examine the call stack of an executing thread, verify source URL’s, and switch between sessions if you are running concurrent debugging sessions.

  • Sessions Window

  • Variables Window

  • Watches Window

  • Call Stack Window

  • Threads Window

  • Sources Window

  • Breakpoints Window

All debugger windows can be accessed from the IDE’s Window > Debugging menu. Once a debugging session is active, you can begin making use of the debugger windows.

Figure 5. Debugger menu accessed from the IDE’s main menu

Sessions Window

The Sessions window shows any debugging sessions that are currently active. When you start a PHP debugging session, you can see an entry for the PHP debugger in the Sessions window.

The NetBeans IDE also enables you to run multiple debugger sessions simultaneously. For example, you can debug a Java and a PHP project at the same time. In this case, you can identify two sessions listed in the Sessions window.

The current session (i.e., the session that you can control using the debugger toolbar) is indicated by the more prominent icon (

). To switch sessions, you can double-click on the session you want to make current, or right-click a non-current session and choose Make Current.

*Note: *It is not recommended to switch sessions if the session you are currently working in is suspended.

You can also use the right-click pop-up window to terminate a session (right-click and choose Finish), or toggle between debugging the current thread or all threads within the session (right-click and choose Scope > Debug All Threads or Debug Current Thread).

Variables Window

When the debugger is suspended, the Variables window displays the variables of the current window object for the selected callstack frame. A node is displayed for every variable in the current window. Superglobals are grouped under a separate node.

As you step through the code, the values of some local variables may change. Such local variables are shown in bold in the Local variables window. You can also click directly into the Value column and manually change variable values.

Watches Window

Setting watches destabilizes XDebug and is not recommended. Watches are disabled by default. However if you want to set watches, see Using Additional Watches.

Call Stack Window

The Call Stack window lists the sequence of calls made during execution. When the debugger is suspended, the Call Stack window shows the sequence of function calls (i.e., the call stack). On initial suspension, the top-most stack frame is selected automatically. Double-click on a function call in the window to go to that line in the editor. If the call is made to a PHP class, the Navigator window will also go to that line when you double-click the call.

You can double-click on a call stack frame to select it, then explore any variable or expression values for that frame in the Variables and Watches windows.

Threads Window

The Threads window indicates which PHP script is currently active and whether it is suspended at a breakpoint or running. If the script is running, you need to go to the browser window and interact with the script.

Sources Window

The Sources window displays all the files and scripts loaded for the debugging session. The Sources window does not currently function for PHP projects.

Breakpoints Window

You can use the Breakpoints window to view all breakpoints that you have set in the IDE.

From the Breakpoints window you can enable or disable breakpoints in the Context window. You can also create breakpoint groups.

Can I debug PHP?

A: You can easily debug PHP in Chrome using a simple extension called PHP Console. Just install this PHP debugging tool from the Chrome web store and start logging errors, warnings, exceptions, and vars dump on your Chrome browser.

What is debug mode in PHP?

E_NOTICE is useful during development since it will tell you about defects such as unassigned variables. display_errors tells PHP if and where to display error messages. display_startup_errors should only be used when debugging. log_errors and error_log work together to send errors to a log file.

How do I debug PHP locally?

To locally debug a PHP Script:.
Set breakpoints at the relevant places in the file that you would like to debug by double-clicking the vertical marker bar to the left of the editor..
Save the file..
Click the arrow next to the debug button. ... .
Double-click the PHP Script option to create a new debug configuration..

Which function is useful for debugging in PHP?

Xdebug is a PHP extension which provides debugging capabilities. It uses the DBGp debugging protocol. Xdebug is a PHP extension which provides debugging and profiling capabilities.