bernhard Posted April 23, 2018 Share Posted April 23, 2018 I love TracyDebugger, but today I had a hard time debugging some stuff and tried XDebug to get support for breakpoints. It was a quite straightforward setup: create a file on your server and output phpinfo() Copy the content of this page to the wizard: https://xdebug.org/wizard.php DON'T follow the instructions there, it's simpler with laragon (choose your files and paths of course): Download php_xdebug-2.6.0-7.1-vc14-x86_64.dll Move the downloaded file to C:\laragon\bin\php\php-7.1.14-Win32-VC14-x64\ext Enable xdebug via laragon check if everything worked by visiting the phpinfo() page again - it should show a section about xdebug now enable validaton in vscode by adjusting the user settings: "php.validate.enable": true, "php.validate.executablePath": "C:/laragon/bin/php/php-7.1.14-Win32-VC14-x64/php.exe", "php.validate.run": "onType", install "PHP Debug" extension by Felix Becker and read the instructions enable remote debugging by xdebug by adding this to your php.ini [XDebug] xdebug.remote_enable = 1 xdebug.remote_autostart = 1 create a testfile, eg home.php and set the debug config to "PHP" add breakpoints and start debugging by pressing the green play icon reload your page in the browser and the debugger will stop on lines 2 and 3 where we set the breakpoints. open vscode (if you don't have two screens) and follow code execution step by step. There are also some videos on youtube: https://www.youtube.com/watch?v=poty5nKk2m4 If XDebug slows down your server you can simple enable/disable it via laragon. This will require only two clicks and reload apache automatically 6 1 Link to comment Share on other sites More sharing options...
FrancisChung Posted April 24, 2018 Share Posted April 24, 2018 You're right about XDebug slowing everything to a crawl. Have you tried these tricks involving the profiler and remote host? http://www.sinaru.com/2015/09/25/improving-php-xdebug-speed/ 1 Link to comment Share on other sites More sharing options...
kongondo Posted April 24, 2018 Share Posted April 24, 2018 15 hours ago, bernhard said: If anybody knows how to tackle this, please post the solution in the linked thread and I'll update this tutorial. Thanks We did . 1 Link to comment Share on other sites More sharing options...
bernhard Posted April 24, 2018 Author Share Posted April 24, 2018 Thx @FrancisChung and @kongondo, the quickest possible fix was to just copy laragon's php binary folder, rename it to php...-noXDebug and remove the .dll and comment out the section for xdebug in php.ini You can enable/disable php extensions with a simple rightclick in laragon: 2 Link to comment Share on other sites More sharing options...
stand-ground Posted May 13, 2018 Share Posted May 13, 2018 ? Link to comment Share on other sites More sharing options...
bernhard Posted May 13, 2018 Author Share Posted May 13, 2018 28 minutes ago, stand-ground said: ? Could you please tell us what you mean by that? 1 Link to comment Share on other sites More sharing options...
stand-ground Posted May 24, 2018 Share Posted May 24, 2018 On 5/13/2018 at 3:01 PM, bernhard said: Could you please tell us what you mean by that? Whoops. Pasted the wrong emoji Link to comment Share on other sites More sharing options...
JohnClarkeAu Posted August 22, 2019 Share Posted August 22, 2019 Hi Bernhard, Thank you for an excellent write up. I can finally debug my WordPress plugins after several years of trying! Cheers, John Link to comment Share on other sites More sharing options...
graziano Posted February 3, 2020 Share Posted February 3, 2020 Hello I followed instruction at first step ( bernhard ) , all is ok , however .. at this step "create a testfile, eg home.php and set the debug config to "PHP" " I have something different in my Visual Studio , I have this How can I proceed ? What folder should I setup and what is lanuch.json ? Really no idea at this step . I want that when I click Ctrl+f5 ("run without debugging") Visual studio open the browser to http://localhost/myscript.php but when I do this Ctrl+f5 , Visual studio ask me to choose an enviroment between PHP and Node.js , I select PHP but nothing happens. Link to comment Share on other sites More sharing options...
bernhard Posted May 5, 2020 Author Share Posted May 5, 2020 On 2/3/2020 at 2:35 PM, graziano said: Sorry @graziano I had to use and install XDebug today and stumbled over this as well. For future reference or others having the same problem this is what worked for me: { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000 }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9000 } ] } Fortunately VSCode now has a direct link and this file should be created automatically once you click on it: Once the launch.json file exists the panel will change and you will be able to listen for xdebug: 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now