- Install VS COde
- Install or copy PHP executable https://www.php.net/downloads
- For windows if you don’t know what to download , just download VS16 x64 Thread Safe https://windows.php.net/download#php-8.1
- unzip the file and copy it to place where it is easily accessiable.
- Add some Json files in Settings of VS code. (navigate to File -> Preferences -> Settings)
- Click on “Open Json settings button on top right side icon” It will open settings.json file
- Paste following code block in it, correct the runtime execuatable file path accordingly.
{ "launch": { "configurations": [ { "type": "php", "request": "launch", "name": "Run using local PHP Interpreter", "program": "${file}", "runtimeExecutable": "C:\\php\\php.exe" }], } }
6. Now install the extension, go to the extension tab in VS Code and search “PHP” install PHP Debug by Felix Becker, Now VS code is ready to execute PHP in VS Code.
Note: if you don’t want to use VS Code to run PHP code, you can also use online editor Implode https://implode.io/