简体   繁体   中英

Xdebug in VScode is not working by 'artisan serve' in MacOs

I'm trying to debug a Laravel project in my MacOs but it's not working (Laravel + VScode + Xdebug).

phpinfo

phpinfo1

phpinfo2

php.ini

;zend_extension="xdebug.so"
[PHP]
zend_extension = /usr/local/lib/php/pecl/20190902/xdebug.so
xdebug.remote_enable = 1 
xdebug.remote_connect_back=1
xdebug.remote_port = 8000 
xdebug.scream=0 

launch.json

{
    // 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": 8000,
            "log": true
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 8000
        }
    ]
}

VScode editor VScode editor screenshot

Debug console of VScode

connection closed
connection closed

After run php artisan serve on terminal of VScode. The laravel project was running but the Xdebug was not trigged as i expected. I don't know what is the problem. I've spent for several time but still could not be solved. Anyone who had experienced with VScode + Xdebug please help me.

Thank you for reading my post.

It's working now. After i changed the Port of 'launch.json' to 9000 and updated the 'php.ini' to " [xdebug] xdebug.remote_enable=1 xdebug.remote_autostart=1 " removed all old content. Finally, run the command "sudo apachectl restart". Now i can debug my laravel project. Thank you @LazyOne for supporting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM