How do i debug php code in visual studio?
Show
Debugging of PHP code in VS Code allows for inspecting a PHP program, inspecting actual variables, stack traces, exceptions, breaking and stepping through the code, debugging PHPUnit tests, and more. RequirementsIn order to debug a PHP program, you need PHP (either installed locally or on your server) together with Xdebug extension.
Local PHP InstallationIn case there are more PHP installations on the system, see choosing PHP Version and select the right one. To verify your PHP and Xdebug are installed correctly:
If PHP with Xdebug is installed correctly, you will see
php.ini ConfigurationXdebug needs to be set in
Edit the
Server PHP Installation
In case You can then take advantage of DBGP Proxy to allow multiple users to debug the same site safely. Launching Debug in VSCodeLaunch debugging in Visual Studio Code to either run the program and debug, or to listen for
incoming Xdebug connections and debug. PHP debugging can be initiated in several ways, with or without VS Code Workspace, with or without the configured With launch.json
No launch.json, Just DebugDebugging can be started without any configuration. This is recommended if you just need to attach to an existing Web Server (with Xdebug configured) or to quickly run and debug a PHP script.
FeaturesThe debugging features are the following:
Debug AdornmentsWhen stepping through the code, the editor will display values of variables and expressions corresponding to the current statement. Values are also shown for the enclosing scopes such as loop control variables, switch expression, and function parameters. This feature can be enabled or disabled using VS Code Setting Start Debug and Stop on EntryOpen command palette and run TroubleshootingThese are steps that should help to diagnose and solve common problems with debugging PHP:
See Also
How do I Debug PHP code?Debugging Session. Start the ide and open the file that contains the source code that you want to debug.. Set a breakpoint at each line where you want the debugger to pause. ... . In the Projects window, navigate to the current project node, click the right mouse button, and choose Debug from the popup menu.. How do I test PHP code in Visual Studio?There is a much easier way to run PHP, no configuration needed:. Install the Code Runner Extension.. Open the PHP code file in Text Editor. use shortcut Ctrl+Alt+N. or press F1 and then select/type Run Code , or right click the Text Editor and then click Run Code in editor context menu.. How do I Debug my code in Visual Studio?Applies to: Visual Studio Visual Studio for Mac Visual Studio Code.. To debug, you need to start your app with the debugger attached to the app process. ... . Press F5 (Debug > Start Debugging) or the Start Debugging button. ... . To start your app with the debugger attached, press F11 (Debug > Step Into).. How do I activate PHP code in Visual Studio?PHP in Visual Studio Code. validate. enable : controls whether to enable PHP linting at all. Enabled by default.. validate. executablePath : points to the PHP executable on disk. ... . validate. run : controls whether the validation is triggered on save (value: "onSave" ) or on type (value: "onType" ).. |