Introducing Xdebug in PHP with vscode

Tram Ho

I. Introduction.

1. What is a Debug?

  • Programming is a job that requires high accuracy when only a small omission such as: typing the wrong syntax, forgetting semicolons is quite common in programmers. Such bugs may lead to the application not working or working in a different direction than the request is issued. When programming even simple applications, it is inevitable to make mistakes when writing code.
  • So finding and finding bugs to fix is ​​commonplace for programmers. The process of finding and discovering this error is also known as debugging.
  • For simple applications, the error detection does not take too much time, but when working with large applications, finding fault will be very difficult. Good programmers are also people who find bugs very quickly and accurately. This article will help you understand the debugging process and then get familiar with debugging in PHP.

2. What is Xdebug?

  • Xdebug is a library written to help you find bugs in PHP applications more efficiently.
  • Tools to find application errors such as Xdebug are called debuggers.

II. Use Xdebug with vscode.

1. Install

Step 1:

  • Xdebug is simply a .dll file, you can go to this download link: .
  • Some handy links to install Xdebug:
    • MAMP
    • MAMP Pro
    • VVV
    • Local By Flywheel
    • Valet
    • Desktop Server
  • Create an index.php file in the root directory of your web and add the following code.

  • Run the index.php file in the browser. Then some of the following information as shown:

Step 2:

  • Add the Xdebug configuration to php.ini

[XDebug] zend_extension=C:xamppphpextphp_xdebug-2.5.4-5.6-vc11.dll xdebug.remote_enable = 1 xdebug.remote_autostart = 1

Step 3: Install the PHP Debug Extension in VS Code

  • Open Visual Code and go to Extension to search for PHP Debug and install:
  • You have now completed the Xdebug installation steps for Visual Code.


Share the news now

Source : Viblo