0

I'm trying to debug a laravel app using vscode. It seems that xdebug is connecting but I'm having no luck so far with the breakpoints. I have set a few but it is not stopping as intended.

Here is my config and logs.

I start listening in vscode with F5, and then I run php artisan serve on the terminal.

php.ini ->

[XDebug]
zend_extension=C:\xampp\php\ext\php_xdebug-2.9.2-7.3-vc15-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_port=9091
xdebug.remote_host=127.0.0.1
xdebug.remote_log=C:\xampp\xdebug.log
xdebug.idekey=VSCODE

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": 9091,
            "log": true
        }
    ]
}

C:\xampp\xdebug.log

[241672] Log opened at 2020-02-28 20:02:30
[241672] I: Connecting to configured address/port: 127.0.0.1:9091.
[241672] I: Connected to client. :-)
[241672] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///C:/Development/Menuu/menuu_backend_dev/artisan" language="PHP" xdebug:language_version="7.3.13" protocol_version="1.0" appid="241672" idekey="VSCODE"><engine version="2.9.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

[241672] <- breakpoint_list -i 1
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>

[241672] <- breakpoint_set -i 2 -t line -f file:///c:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php -n 48
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="1106000001"></response>

[241672] <- breakpoint_list -i 3
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- breakpoint_set -i 4 -t line -f file:///c:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php -n 40
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="1106000002"></response>

[241672] <- breakpoint_list -i 5
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="5"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php" lineno="40" state="enabled" hit_count="0" hit_value="0" id="1106000002"></breakpoint><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- breakpoint_list -i 6
[241672] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="6"><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/API/Driver/UserAPIController.php" lineno="40" state="enabled" hit_count="0" hit_value="0" id="1106000002"></breakpoint><breakpoint type="line" filename="file:///C:/Development/Menuu/menuu_backend_dev/app/Http/Controllers/Auth/LoginController.php" lineno="48" state="enabled" hit_count="0" hit_value="0" id="1106000001"></breakpoint></response>

[241672] <- run -i 7
5
  • Have you taken a look at using this VSCode extension? https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug It provides documentation to setup with xdebug. Commented Feb 28, 2020 at 20:15
  • Do the files in the <init packet and breakpoint_set commands match with files on disk? Commented Feb 29, 2020 at 1:27
  • fileuri="file:///C:/Development/Menuu/menuu_backend_dev/artisan" this is the only URI that is wrong, i am running "php artisan serve" as usual Commented Feb 29, 2020 at 2:00
  • How is the URL wrong? That's the one that Xdebug actually sees as PHP code being run. Is it possible that "php artisan serve" ends up calling that script? Commented Feb 29, 2020 at 23:36
  • yes you are right!! i was wrong that uri was fine, there is a artisan file without extension and a server.php at root level in any laravel project, but for some reason is not stopping on breakpoints. if i launch with php -S works fine, and the logs shows file:///C:/Development/Menuu/menuu_backend_dev/server.php intead of /artisan, i will use php -S or just use apache when i need to debug, i just start with laravel and php a few weeks ago and this was driving me crazy :P thanks for the help! Commented Mar 1, 2020 at 2:25

1 Answer 1

-2

Place your breakpoints on lines that have code.

If you place your breakpoints on BLANK LINES it will not work, it will just skip them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.