1

First, I turned on XAMPP and started the following services:

The services that I started in XAMPP - screenshot

By the way, the PHP Version is 7.3.3. Then I checked phpinfo() in the browser. Here is a screenshot:

phpinfo() - screenshot

And I went xdebug.org to download this version of Xdebug:

The Xdebug version I've downloaded - screenshot

When I copied this file to C:\xampp\php\ext, I found there is a file named php_xdebug.dll. Whatever, I still called the Xdebug file into the path without its name changed (php_xdebug-2.7.2-7.3-vc15-x86_64.dll).

Next, I copied a piece of code into php.ini from an article on the Internet:

zend_extension = "C:\xampp\php\ext\php_xdebug-2.7.2-7.3-vc15-x86_64.dll"
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000

But I couldn't figure out why the port was 9000 and the port didn't work at all. I entered localhost:9000 in the address bar of Chrome and the results page shows that localhost rejected my connection request.

However, I still went on. I installed the "PHP Debug" extension in VS Code. The extension's launch.json is shown below:

{
    "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
        }
    ]
}

Finally, I created a new PHP file and debugged it. When I opened the file in the browser, the debug program didn't work. So, could you please tell me where the problem is and show me the exact debugging steps?


update: Finally, I found what the problem is, the 9000 port number is occupied! So I typed ‘netstat -ano’ in cmd and found port 9000 and the corresponding PID value. enter image description hereThen type 'taskkill /PID 4380 /F' to kill the process that occupies the port. Finally, restart the PHP services. Thus, this issue has been solved. But remember, make sure you install the correct xdebug version, which you can view in XAMPP's phpinfo(). Thanks to the friends in the comment area for your help.

2
  • 1
    Did you restart XAMPP (i.e. reload PHP in the server)? Likewise, does an Xdebug section show up when you run phpinfo()? – Anaksunaman May 21 '19 at 14:58
  • Compare your installation with this cookbook. – harrymc May 21 '19 at 20:09
0

You dont need to open 9000 port, you just run debug like:

enter image description here

then

enter image description here

choose PHP

enter image description here

start and play green icon

enter image description here

add break point into your methods or controllers

enter image description here

manage your breakpoints

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.