xdebug Breakpoints not hit in all scripts (Laravel 3) Follow
I'm pretty desperate and running out of idea:
I've configured xdebug and PhpStorm for a Laravel 3 project. Running the project locally on Mac OS X Apache, so PhpStorm and the web application run on the same machine. Configured a virtual host so that localhost.lt points to Laravel's public directory.
Relevant xdebug entries in php.ini:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
[xdebug]
xdebug.idekey="PHPSTORM"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_log=/var/log/xdebug_remote.log
xdebug.remote_connect_back=1
Confirmed that extension gets loaded.
Set up a PHP Web Application debug / run configuration without any path mappings as nothing is symlinked and the folders on the web server and for PhpStorm are exactly the same (as the web server is on the same machine).
When launching via "Debug" from the IDE, xdebug_remote.log correctly shows the breakpoint we've set in one of the files in application/libraries:
<- breakpoint_set -i 5 -t line -f file:///Users/RalfR/src/livetime/application/libraries/LiveTime.php -n 676
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="9230016"></response>
However, when we click a link that invokes the function from the LiveTime.php library, the breakpoint is NOT hit. The log shows:
<- stack_get -i 6
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="stack_get" transaction_id="6"><stack where="{main}" level="0" type="file" filename="file:///Users/RalfR/src/livetime/public/index.php" lineno="14"></stack></response>
<- run -i 7
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="stopping" reason="ok"></response>
<- run -i 8
Log closed at 2013-04-22 21:03:57
As many frameworks, Laravel uses .htaccess mod_rewrite to pipe everything through public/index.php. May this be the cause for PhpStorm / xdebug not catching the breakpoint in application/libraries/LiveTime.php as it appears to xdebug that the LiveTime.php script is never executed?
If so, how can we solve this problem?
Please sign in to leave a comment.
Also, adding
xdebug_break();
anywhere works like a charm so it's not a misconfigured PHP environment. It must have something to do with mod_rewrite, path mappings and PhpStorm.
Hi there,
It's hard to say what is possibly going on wrong. For example, one user reported that the path to the file is wrong (works OK only with lowercase "users" as in "/users/USERNAME/...", when folder is clearly named "/Users/...")
I may suggest:
It even could be something like in this thread: it worked, then it stopped working .. and now it's working again: http://devnet.jetbrains.com/thread/443701 -- no idea.
P.S.
Rather unrelated: having debugger and profiler turned on at the same time does not make much sense (performance data will be incorrect) -- better have some bookmarklet or browser extension to control them (turn on/off when required)
BTW
URL rewriting does NOT matter here at all -- xdebug works with file names only (e.g. if it is symlinked, it will use final/real/resolved location) and PhpStorm works with project files (and path mappings if required)
Thanks, Andriy!
Good to know that mod_rewrite cannot be the root cause. Question: Where do I find the IDE side of the logs to provide you with more info?
We tested a ver simple mini setup and put a breakpoint in next.php on line 3.
It worked like a charm and PhPStorm / xdebug hit the breakpoint right away. In the xdebug log we could see:
And when we clicked the next link:
So clearly those are absolutely identical and match, hence xdebug broke.
Next we created a clear new project from our existing files (removed the .idea folder before and everything PhpStorm related).
Again we saw that the IDE reported the correct breakpoints to xdebug:
However, when we click a link that involves the pushio.php script, the xdebug log shows the following:
This time, due to the way the framework (Laravel and many others) creates pretty URLs, mod_rewrite kicks in and the link is piped through index.php. As index.php is not pushio.php, we believe, xdebug does not understand it has to break.
Can you help us resolving this?
Also, on further investigation, not using a run config but switching the IDE to listening for incoming connections does work, too. When we refresh the page, xdebug log clearly gets the correct info about the breakpoint but then again, when we click, it goes through the rewritten URL and does not trigger the breakpoint.
Help | Show log in ...
P.S.
I'm not a dev or JB staff -- just ordinary PhpStorm user.
Once again -- URL rewriting does not matter. I've been using it with Apapche and mod_rewrite for few years .. and now using IIS 7.x with URL rewrite module -- never had any issues in this regard as xdebug works with FILES only -- it does not care about URLs AT ALL.
If IDE sends wrong file name/line number with breakpoint to xdebug, then it's either misconfiguration (user's fault) or IDE bug. If path is OK but xdebug (somehow) reacts with different/wrong file, then it most likely xdebug issue.
BTW -- what is your xdebug version?
Could you please create very basic Laravel project and attach here (must be self contained -- contain all files required for execution; no DB please). Maybe I can spot something here (on my Windows 7 x64; PHP 5.4.14; IIS 7.5)