bernhard

How to use XDebug with Laragon + VSCode

Recommended Posts

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

5ae30304e1f36_2018-04-2713_00_49-.png.aef0628e41ce7f2de3abc131d3977e13.png

  • 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"

5addf3a10effe_2018-04-2316_44_48-Rechner.png.b95d5bde7f80e3d194b75d008e9ebd39.png

  • add breakpoints and start debugging by pressing the green play icon

5addf4612436c_2018-04-2316_56_18-LaragonFull3.1.9180227php-7.1.14-Win32-VC14-x64192_168.0_18TS.png.243b92149895f88dc0896600a88e7c15.png

  • 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 :)

 

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites
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 :).

  • Like 1

Share this post


Link to post
Share on other sites

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:

2018-04-27 13_00_49-.png

  • Like 2

Share this post


Link to post
Share on other sites
28 minutes ago, stand-ground said:

👎

Could you please tell us what you mean by that?

  • Like 1

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.