PhpStorm: xdebug - How to rewrite class paths?

The PHP-framework I am trying to debug generates cached proxy classes. Adding a breakpoint to the original classes won't do anything because of this. 

Is it possible to hook into or replace the XDebugger, so that my plugin can modify the filepaths that are being received and send?

8 comments
Official comment

Classes are generated for each execution and always have different paths, aren't they? Otherwise, you can configure path mappings in 'PHP|Servers' or for specified cli interpreter. 

Do you debug web server application with 'Zero-configuration' debugger or PHP Script? If you debug PHP Script, is it located locally or remotely?

Unfortunately, the path mapping does not work in this case. Both the filename and directory structure are different from the original class file. Is it possible for a plugin to implement some kind of dynamic path mapping?

If that's not possible I would have to implement a proxy which does the rewriting.

0

> Both the filename and directory structure are different from the original class file.

It is possible to define path mapping for both directory and file for remote interpreters or 'Zero-configuration' debugger.

 

Would you please elaborate our use case, so I can understand if it is supported or not? What kind of debugging do you perform? Do you have some dynamic pattern for path mapping and manual configuration will be tedious?

0

These are examples of classes I want to map:

Data/Temporary/Development/SubContextDocker/Cache/Code/Flow_Object_Classes/TYPO3_TypoScript_Package.php <--> Packages/Application/TYPO3.TypoScript/Classes/TYPO3/TypoScript/Package.php

Data/Temporary/Development/SubContextDocker/Cache/Code/Flow_Object_Classes/TYPO3_Eel_Utility.php <--> Packages/Framework/TYPO3.Eel/Classes/TYPO3/Eel/Utility.php

Whether the original class is in the Framework or Application subdirectory is not possible to determine by the path alone. I can't imagine this is possible to map with the build in PHP debugger. So the question is: Can a plugin extend the XDebugger in a way to support this?

0

Are you using 'Zero-configuration' debug or 'PHP Script' run-configuration?

0

I'm trying to use zero-configuration debugging. By 'PHP-Script debugging' you mean CLI scripts, right?

0

> By 'PHP-Script debugging' you mean CLI scripts, right?

Yes, I mean CLI scripts.

 

Unfortunately, I see only one option - generate 'PhpServer' object (which can be configured manually in PHP|Servers) automatically with all mappings, but you'll still need to know all mappings before debug session initialization.

At the moment we are also considering to support sourcemap (https://youtrack.jetbrains.com/issue/WI-31431). Will it solve your problem?

0

The framework would just need to generate the sourcemaps then. Looks promising and should solve this use case!

0

Please sign in to leave a comment.