Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run or debug php on Visual Studio Code (VSCode)

I can't find a way to run or debug php on Visual studio code, Does anyone know how?

like image 562
omer2802 Avatar asked Apr 30 '15 06:04

omer2802


People also ask

How do you run and debug in VS Code?

To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and VS Code will try to run your currently active file. However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.


2 Answers

Debugging PHP with VSCode using the vscode-php-debug extension

VSCode can now support debugging PHP projects through the marketplace extension vscode-php-debug.

This extension uses XDebug in the background, and allows you to use breakpoints, watches, stack traces and the like:

Screenshot: PHP Debugging in VSCode using vscode-php-debug extension

Installation is straightforward from within VSCode: Summon the command line with F1 and then type ext install php-debug

like image 148
flexponsive Avatar answered Sep 18 '22 13:09

flexponsive


As far as I read about it today, you can't debug anything else than node.js, JavaScript and TypeScript at the moment, but they said they want to add new languages which you can debug. The editor is still in development. Nevertheless, I don't think there will be a php debugger in the future since php is serverside, so you can't debug it on your client alone.

If you want to debug php, I can recommend xDebug.


Updated:

Now, it is possible to debug with VS code. You need to install XDebug and php-debug extension for VScode.

like image 44
Realitätsverlust Avatar answered Sep 20 '22 13:09

Realitätsverlust