All Projects → xdebug → Vscode Php Debug

xdebug / Vscode Php Debug

Licence: mit
PHP Debug Adapter for Visual Studio Code 🐞⛔

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vscode Php Debug

Hashlink Debugger
Visual Studio Code Debugger for Haxe/HashLink applications
Stars: ✭ 35 (-93.85%)
Mutual labels:  vscode, vscode-extension, debugger
Hxcpp Debugger
Visual Studio Code Debugger for Haxe/HXCPP applications
Stars: ✭ 18 (-96.84%)
Mutual labels:  vscode, vscode-extension, debugger
Vscode Go
Go extension for Visual Studio Code
Stars: ✭ 2,268 (+298.59%)
Mutual labels:  debugger, vscode, vscode-extension
Android Dev Ext
Android debugging support for VS Code
Stars: ✭ 141 (-75.22%)
Mutual labels:  vscode, vscode-extension, debugger
Chrome Vs Code
A web browser integrated in VS Code editor tabs. ☢️ experimental ☢️
Stars: ✭ 351 (-38.31%)
Mutual labels:  vscode, vscode-extension
Shades Of Purple Vscode
🦄 Shades of Purple — A professional theme with hand-picked & bold shades of purple to go along with your VSCode. Reviewed by several designers and 75+ theme versions released to keep it updated. One of the top rated best VSCode themes on VS Code Marketplace. Download →
Stars: ✭ 486 (-14.59%)
Mutual labels:  vscode, vscode-extension
Vscode Angular Snippets
Angular Snippets for VS Code
Stars: ✭ 530 (-6.85%)
Mutual labels:  vscode, vscode-extension
Vscode Syncing
⚡️ VSCode Extension - Sync all of your VSCode settings across multiple devices.
Stars: ✭ 395 (-30.58%)
Mutual labels:  vscode, vscode-extension
Xdebug Helper For Chrome
Easily activate PHP debugging, profiling and tracing with this Xdebug Chrome extension
Stars: ✭ 270 (-52.55%)
Mutual labels:  debugger, xdebug
Awesome Vscode
🎨 A curated list of delightful VS Code packages and resources.
Stars: ✭ 19,659 (+3355.01%)
Mutual labels:  vscode, vscode-extension
Vscode Graphql
VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
Stars: ✭ 435 (-23.55%)
Mutual labels:  vscode, vscode-extension
Vscode Live Sass Compiler
Compile Sass or Scss file to CSS at realtime with live browser reload feature.
Stars: ✭ 488 (-14.24%)
Mutual labels:  vscode, vscode-extension
Vscode Winddown
VS Code extension that encourages you to take a break.
Stars: ✭ 299 (-47.45%)
Mutual labels:  vscode, vscode-extension
Vscode Php Intellisense
Advanced PHP IntelliSense for Visual Studio Code 🆚💬
Stars: ✭ 358 (-37.08%)
Mutual labels:  vscode, vscode-extension
Vscode Reveal
Revealjs vsCode extension
Stars: ✭ 298 (-47.63%)
Mutual labels:  vscode, vscode-extension
Iceworks
Visual Intelligent Development Pack(可视化智能开发套件)
Stars: ✭ 390 (-31.46%)
Mutual labels:  vscode, vscode-extension
Marp Vscode
Marp for VS Code: Create slide deck written in Marp Markdown on VS Code
Stars: ✭ 442 (-22.32%)
Mutual labels:  vscode, vscode-extension
Edamagit
Magit for VSCode
Stars: ✭ 440 (-22.67%)
Mutual labels:  vscode, vscode-extension
Evermonkey
Evernote Editing. Redefined. 关于 token 的问题请去 https://github.com/michalyao/evermonkey/issues/94 中查看!
Stars: ✭ 542 (-4.75%)
Mutual labels:  vscode, vscode-extension
Vscode R
R Extension for Visual Studio Code (execution, snippet, lint, R documantation, R Markdown)
Stars: ✭ 445 (-21.79%)
Mutual labels:  vscode, vscode-extension

PHP Debug Adapter for Visual Studio Code

vs marketplace downloads rating build status codecov code style: prettier semantic-release

Demo GIF

Installation

Install the extension: Press F1, type ext install php-debug.

This extension is a debug adapter between VS Code and Xdebug by Derick Rethans. Xdebug is a PHP extension (a .so file on Linux and a .dll on Windows) that needs to be installed on your server.

  1. Install Xdebug I highly recommend you make a simple test.php file, put a phpinfo(); statement in there, then copy the output and paste it into the Xdebug installation wizard. It will analyze it and give you tailored installation instructions for your environment. In short:

    • On Windows: Download the appropriate precompiled DLL for your PHP version, architecture (64/32 Bit), thread safety (TS/NTS) and Visual Studio compiler version and place it in your PHP extension folder.
    • On Linux: Either download the source code as a tarball or clone it with git, then compile it.
  2. Configure PHP to use Xdebug by adding zend_extension=path/to/xdebug to your php.ini. The path of your php.ini is shown in your phpinfo() output under "Loaded Configuration File".

  3. Enable remote debugging in your php.ini:

    For Xdebug v3.x.x:

    xdebug.mode = debug
    xdebug.start_with_request = yes
    xdebug.client_port = 9000
    

    For Xdebug v2.x.x:

    xdebug.remote_enable = 1
    xdebug.remote_autostart = 1
    

    There are other ways to tell Xdebug to connect to a remote debugger, like cookies, query parameters or browser extensions. I recommend remote_autostart (Xdebug v2)/start_with_request (Xdebug v3) because it "just works". There are also a variety of other options, like the port, please see the Xdebug documentation on remote debugging for more information. Please note that the default Xdebug port changed between Xdebug v2 to v3 from 9000 to 9003. The extension still defaults to 9000, so make sure your configuration in launch.json and php.ini match.

  4. If you are doing web development, don't forget to restart your webserver to reload the settings.

  5. Verify your installation by checking your phpinfo() output for an Xdebug section.

VS Code Configuration

In your project, go to the debugger and hit the little gear icon and choose PHP. A new launch configuration will be created for you with two configurations:

  • Listen for Xdebug This setting will simply start listening on the specified port (by default 9000) for Xdebug. If you configured Xdebug like recommended above, everytime you make a request with a browser to your webserver or launch a CLI script Xdebug will connect and you can stop on breakpoints, exceptions etc.
  • Launch currently open script This setting is an example of CLI debugging. It will launch the currently opened script as a CLI, show all stdout/stderr output in the debug console and end the debug session once the script exits.

Supported launch.json settings:

  • request: Always "launch"
  • hostname: The address to bind to when listening for Xdebug (default: all IPv6 connections if available, else all IPv4 connections)
  • port: The port on which to listen for Xdebug (default: 9000)
  • stopOnEntry: Whether to break at the beginning of the script (default: false)
  • pathMappings: A list of server paths mapping to the local source paths on your machine, see "Remote Host Debugging" below
  • log: Whether to log all communication between VS Code and the adapter to the debug console. See Troubleshooting further down.
  • ignore: An optional array of glob patterns that errors should be ignored from (for example **/vendor/**/*.php)
  • xdebugSettings: Allows you to override Xdebug's remote debugging settings to fine tuning Xdebug to your needs. For example, you can play with max_children and max_depth to change the max number of array and object children that are retrieved and the max depth in structures like arrays and objects. This can speed up the debugger on slow machines. For a full list of feature names that can be set please refer to the Xdebug documentation.
    • max_children: max number of array or object children to initially retrieve
    • max_data: max amount of variable data to initially retrieve.
    • max_depth: maximum depth that the debugger engine may return when sending arrays, hashs or object structures to the IDE.
    • show_hidden: This feature can get set by the IDE if it wants to have more detailed internal information on properties (eg. private members of classes, etc.) Zero means that hidden members are not shown to the IDE.

Options specific to CLI debugging:

  • program: Path to the script that should be launched
  • args: Arguments passed to the script
  • cwd: The current working directory to use when launching the script
  • runtimeExecutable: Path to the PHP binary used for launching the script. By default the one on the PATH.
  • runtimeArgs: Additional arguments to pass to the PHP binary
  • externalConsole: Launches the script in an external console window instead of the debug console (default: false)
  • env: Environment variables to pass to the script

Features

  • Line breakpoints
  • Conditional breakpoints
  • Function breakpoints
  • Step over, step in, step out
  • Break on entry
  • Breaking on uncaught exceptions and errors / warnings / notices
  • Multiple, parallel requests
  • Stack traces, scope variables, superglobals, user defined constants
  • Arrays & objects (including classname, private and static properties)
  • Debug console
  • Watches
  • Run as CLI
  • Run without debugging

Remote Host Debugging

To debug a running application on a remote host, you need to tell Xdebug to connect to a different IP than localhost. This can either be done by setting xdebug.remote_host to your IP or by setting xdebug.remote_connect_back = 1 to make Xdebug always connect back to the machine who did the web request. The latter is the only setting that supports multiple users debugging the same server and "just works" for web projects. Again, please see the Xdebug documentation on the subject for more information.

To make VS Code map the files on the server to the right files on your local machine, you have to set the pathMappings settings in your launch.json. Example:

// server -> local
"pathMappings": {
  "/var/www/html": "${workspaceFolder}/www",
  "/app": "${workspaceFolder}/app"
}

Please also note that setting any of the CLI debugging options will not work with remote host debugging, because the script is always launched locally. If you want to debug a CLI script on a remote host, you need to launch it manually from the command line.

Troubleshooting

  • Ask a question on StackOverflow
  • If you think you found a bug, open an issue
  • Make sure you have the latest version of this extension and Xdebug installed
  • Try out a simple PHP file to recreate the issue, for example from the testproject
  • In your php.ini, set xdebug.remote_log = /path/to/logfile (make sure your webserver has write permissions to the file)
  • Set "log": true in your launch.json

Contributing

To hack on this adapter, clone the repository and open it in VS Code. You need NodeJS with NPM installed. Install dependencies by running npm install.

You can debug the extension (run it in "server mode") by selecting the "Debug adapter" launch configuration and hitting F5. Then, open a terminal inside the project, and open the included testproject with VS Code while specifying the current directory as extensionDevelopmentPath:

code testproject --extensionDevelopmentPath=.

VS Code will open an "Extension Development Host" with the debug adapter running. Open .vscode/launch.json and uncomment the debugServer configuration line. Hit F5 to start a debugging session. Now you can debug the testproject like specified above and set breakpoints inside your first VS Code instance to step through the adapter code.

The extension is written in TypeScript. You can compile it through npm run build. npm run watch enables incremental compilation.

Tests are written with Mocha and can be run with npm test. The tests are run in CI on Linux, macOS and Windows against multiple PHP and Xdebug versions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].