doupeng6890
2015-01-21 03:07
浏览 93
已采纳

在XDebug for Eclipse中,远程路径如何映射到本地路径?

Although I now realize that the trick to getting Eclipse to stop at your breakpoints, when PHP scripts are executed from POST and GET requests from ajax/curl, is to make sure the XDEBUG_START_SESSION variable is set in all the requests you want the debugger to be aware of, this seems to only work when all of your paths on the web server are the normal relative kind.

However, if you happen to have some aliased paths on the webserver, such as by way of the httpd Alias directive, XDebug then has trouble associating the paths of the files in your workspace with their path in a site URL.

I have the following directory setup:

Directory Setup

Here's how the web server is setup:

ServerName test.local
DocumentRoot "C:\Users\me\projects\testproject\start\here"
Alias /post "C:\Users\me\projects\testproject\post"

<Directory "C:\Users\me\projects\testproject">
    Require all granted
</Directory>

I would think this is what the Path Mapping tab is for, found in Debug Configurations -> Server -> Configure... -> Path Mapping. Everywhere I look, I'm told to set Path on server to the filesystem path on the webserver for a directory or file, and to set Local path to its path in your filesystem or workspace. I also tried setting Path on server to the site URL path I wanted to map to the Local path, but neither configuration results in breaking on a line in a POSTed PHP script.

I turned on logging for XDebug, to compare messages for a breakpoint that it properly stops on, because it's in the file the the debugger starts at, and a breakpoint in the script executed by way of POST request, which is unfortunately not stopping. It will stop in this file if the /post path correspond with a post directory at the DocumentRoot, but not if the post directory is somewhere else and the "fake" /post path in the site URL is aliased to it.

In my XDebug log file, there are several log entries for line 28 in index.php, the file for which it is properly breaking. Line 3 in message.php has an entry as well, and the URL-encoded path looks correct, but I'm not seeing the same kind of entries.

How can Eclipse be configured to know that /post on the server means /My Project/post in the workspace?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douxin5953 2015-01-25 16:01
    最佳回答

    Oh my... it was simply a matter of setting Accept remote session (JIT) to localhost, in my case, or just anything other than off:

    Accept remote session

    It's great to confirm that this does fundamentally work, but I'm still confused as to why it's not in a much more complex project. With luck, I'll have more to share...

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题