Debugging Magento with PhpStorm

Hi everyone,

I've just set up debugging on my project. And it seemed to work. I've put some breakpoints in index.php which were constantly being hit when debugging over browser.
However, breakpoints that were deeper in the project structure were being missed. Anyone familiar with Magento knows that the cms first targets index.php and then from there dwells deeper into it's MVC structure.
In example, breakpoint placed in CartController.php class was not being hit when accessing site.com/checkout/cart/
Why are my breakpoints in classes being missed? And the ones in index.php are being hit?

Thanks

3 comments
Comment actions Permalink

Hi there,

breakpoint placed in CartController.php class was not being hit when accessing site.com/checkout/cart/

URL does not matter at all -- debugger works with physical files only. If you execute your code on another server (another computer/virtual server), then make sure that debugging paths are set up properly (Settings | PHP | Servers)

Please also note that debugger (at least, xdebug) works with real paths, therefore if you are using symlinks then real/resolved path will still be used. Debugging path mappings can help here as well.

Instead of breakpoint in such "unhittable" file --  try xdebug_break() function (in case you are using xdebug). If it does not work as well -- most likely paths are not properly mapped (or local file is missing).

0
Comment actions Permalink

Using xdebug_break(); triggered PhpStorm asking for path mappings. I've set up path mapping for CartController.php and breakpoint worked! I've done the same thing for a Model class deeper in the code - breakpoint itself was being missed, until I used xdebug_break() just in front of breakpoint - that triggered port mapping in PhpStorm, I've set that up and break point worked. I was then able to remove the xdebug_break();
I thought I didn't have to use path mapping since I'm working on local server, but I'm also using apache overwrites, so probably that's why.. even though absolute path on server and file/directory fields are the same.

Thanks, this solved my issue.

0
Comment actions Permalink

Cool. I'm glad you have managed to resolve your issue.

Just in case you did not know -- you can setup path mappings for whole folder(s) and then all sub-folders/files will inherit it (no need to setup path mappings for each individual file).

0

Please sign in to leave a comment.