简体   繁体   中英

How to properly setup debug configurations in PhpStorm

I have a project in PhpStorm and I would like to be able debug any php file in any folder. The only way I managed to debug a php page was to set it explicitly in the debug configuration:

在此处输入图片说明

Note that I'm typing the full path to a php file in a specific folder. Now if I want to debug another file, I have to create another configuration for that new file. What if I want to debug more 2, 3 files? Do I have to create a new configuration to every single file?

I can also right click a file and then select Debug. It launches in the browser but this way it doesn't stop on the breakpoint (the same breakpoint that it stops in the above example, so both xdebug and chrome extension are working correctly).

It seems that if I right click the file and then select Debug it's creating a temporary configuration but of type 'JavaScript Debug' as can be seen in the following picture:

在此处输入图片说明

Then it makes sense it's not stopping in the breakpoint, since it's expecting Java code. Is there any way to change this? Am I missing something?

This is what I do:

  1. Start the debugger and switch to the browser tab that opened. Note that in the browser a query parameter is added to the URL; something like XDEBUG_SESSION_START=15412 . From then on, the debugger will be activated by any http request that has this parameter set to this value in $_GET , in $_POST or $_COOKIE . You can also see the right value within the IDE. The debugger tab will have the message Waiting for incoming connection with ide key 15412

  2. Here is the key: after I set my breakpoint in the file I want to debug, I just navigate to it in the browser, but I first add the same query parameter to the url. Easy!

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