xdebug Breakpoints not hit in all scripts (Laravel 3)

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

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?
Comment actions Permalink

Also, adding


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.

Comment actions Permalink

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:

  1. What xdebug version do you have there? Make sure you have 2.2.1 or newer (some older versions are unstable or contain other bugs)
  2. Try very basic and simple script first (something like this (each command on new line): <?php $a = 1; $b = 2; $c = $a + $b; echo $c; ) and once figured move to real project
  3. Try #2 in brand new and empty project (with that simple script only) -- try exactly as described here: http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm (maybe even including xdebug configuration: http://confluence.jetbrains.com/display/PhpStorm/Xdebug+Installation+Guide  -- Yes, I know, you have it working already, but just try in case...).
  4. Try collecting debugger logs from IDE side as well -- it may give you some info on possible reasons why breakpoint is not get hit: http://devnet.jetbrains.com/docs/DOC-1202

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.

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)

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)

Comment actions Permalink

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?

Comment actions Permalink

We tested a ver simple mini setup and put a breakpoint in next.php on line 3.


<?php echo("hello world"); ?> <br /> <a href='/next.php'>link</a>


<?php     $time = time();     $greet = "The time is ".$time;     echo $greet; ?>

It worked like a charm and PhPStorm / xdebug hit the breakpoint right away. In the xdebug log we could see:

<- breakpoint_set -i 5 -t line -f file:///Users/RalfR/src/playground/next.php -n 3

And when we clicked the next link:

<response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="run" transaction_id="7" status="break" reason="ok">
<xdebug:message filename="file:///Users/RalfR/src/playground/next.php" lineno="3"></xdebug:message>

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:

<- breakpoint_set -i 5 -t line -f file:///Users/RalfR/src/lt/application/libraries/pushio.php -n 18 ->

However, when we click a link that involves the pushio.php script, the xdebug log shows the following:

<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/lt/public/index.php" lineno="14"></stack>

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?
Comment actions Permalink

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.

Comment actions Permalink
Question: Where do I find the IDE side of the logs to provide you with more info?

Help | Show log in ...

I'm not a dev or JB staff -- just ordinary PhpStorm user.

Comment actions Permalink

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.

  1. Xdebug is the one who initiates the session (xdebug connects to IDE when it sees xdebug session (cookie/get/post param etc) request .. or if it is configured to initiate debug connection on every single request)
  2. IDE accepts or rejects connection (e.g. when debugger is off or whatever)
  3. Once connection accepted, IDE sends a list of breakpoints and other configuration data (like, stop on first line of each script etc etc)
  4. If you have no path mappings defined (Preferences | PHP | Servers), the file path is sent as it is known to PhpStorm, otherwise mapped/transformed path is used (as xdebug works with resolved/final file names only)

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)


Please sign in to leave a comment.