Follow these steps to configure XDebug in VSCode:
- Save your project as a workspace in VSCode
- Install PHP debugger extension in VSCode.
- Install xdebug on your system. https://xdebug.org/docs/install
- Create a
phpinfo()inside that file.
- Access that file into your browser. You will see your phpinfo like this
- Select everything you see on this page and add it to xdebug wizard.
- Follow the xdebug wizard https://xdebug.org/wizard instructions.
- After following xdebug wizard instructions, add these two lines to your
xdebug.client_host = localhost
xdebug.client_port = 9003
- Restart Apache/Sevrver( MAMP, XAMP, WAMP )
- Go to debugger and create a launch.json
- Select project
- Select PHP
- Your json file is generated now and it will look like this
- Listen for Xdebug.
- Add a breakpoint where you want to debug. Click on the line number to set break point
- Open the site in the browser and visit the page where your code executes where you added a breakpoint.
- You will see the debugging info in debugger
That’s it !!!!