I would like to setup debugging but I am not sure how to go about doing it. The documentation indicates that PHPStorm supports both Zend and XDebug. Which is easier to set up? It seems that Zend costs money after a trial period. At this point I would very much appreciate a step-by-step tutorial on setting up and initiating a debug session.

In my particular case I install PHP with XAMPP and this also installs Apache and MySql. I also install Moodle as an XAMPP application. I am developing a PHP plugin for Moodle and it is here that I want to set breakpoints and debug. I can start the PHP Moodle application by pointing my browser at http://localhost/Mooodle but I am not sure how to set a breakpoint since the project that I have in PHPStorm is just the plugin. Do I need to somehow debug all of Moodle in order to set a breakpoint in this plugin?

Thank you.



Thank you.

I have installed XDebug and php -i shows that it is installed. I have started listening for the debugger on my project. I have set a number of breakpoints. I have clicked on the link to 'Start debugger' from Chrome given my IDE key (which is reported using phpinfo()).By the way there is no output from clicking on the hyperlink 'Start debugger'. I start Moodle by pointing my browser (Chrome) at the appropriate URL (yes it is local). I go through a series of steps that should trigger the breakpoint in my project but nothing happens. How do I know that the debugger is active or I just have not set a breakpoint in the right spot?

Thank you.


I have installed XDebug and php -i shows that it is installed

What OS you are on? On some OS (or, better say, Apache/PHP distributions) PHP may have two different config files -- one for CLI mode and one when used by Apache.

Does both of them show xdebug installed (I mean: "php -i" for CLI and <?php phpinfo(); ?> for web) ?

By the way there is no output from clicking on the hyperlink 'Start debugger'

It's normal -- all what "Start Debugger" bookmarklet does is setting up xdebug cookie ONLY.

How do I know that the debugger is active or I just have not set a breakpoint in the right spot?

1) Put xdebug_break(); somewhere in your code -- this will programmatically trigger breakpoint.

2) Please show output of phpinfo(); when you trying to debug (header table (where I can see that xdebug is installed and other relevant info); actual xdebug section; PHP Variables section (I just want to see if xdebug cookie/get param is there))

3) Some breakpoints cannot be hit by xdebug due to the way how PHP generates bytecode (e.g. multiline array definitions; simple "if" statement with no braces used etc). Always try to set breakpoints on simple one-liners.

4) Collect more logs and check them for details:

You will easily see from xdebug log if xdebug tries to connect to IDE or not. If not -- it's either disabled or does not see debug request (cookie/get parameter)

BTW: what xdebug version do you have? It's recommended to be v2.2.1 or newer (2.2.0 is quite unstable .. but should not prevent from not working at all).

My general advice:
instead of trying to debug complex app straight away -- create brand new empty project/site with one simple (few lines) file only and try to make debugger work there. Once you make it working -- try real project. Simple file to debug:

$a = 5;
$b = 4;
$z = $a + $b;
echo $z;


I have attached the output from php -i.

It turns out that the IDE is showing an 'error' that

Remote file path 'C:\xampp\apps\moodle\htdocs\course\jumpto.php' is not mapped to any file path in project

And below that there is a hyperlink 'Click to set up path mappings'. I click on this link and it doesn't seem that there is anything that I can change. The 'File path in project' shows undefined and a red exclamation point but the text input seems to be disabled. The OK button on the bottom of the dialog is disabled so the only button I can press is Cancel.

I looked at the project settings and I see that the root is C:\xampp\htdocs and to add a path to the mappings there is a message that the path has to be relative to the root. How should the path mappings me configured and using what tool?

Thank you.


By the way I did try a 'simple' application and I was able to break on that app.


I assume you have symbolic link (or junction point) somewhere in that path. Xdebug works with real (resolved) file paths ONLY while PHP/IDE can work with any.

Please show screenshot of your "Settings | PHP | Servers" (that's where you can manually define them).

Also -- what is the project root (path -- you should see it in Project View panel).


Here is a screen shot of the settings:

Here is the root of the project:


I am on Windows so I am not familiar with symbolic links on Windows.

Thank you.



Based on your screenshots and info:

The file xdebug is trying to debug (you are trying to execute) is

while project root is

(I've marked common part with bold font)

As you can see the "course\jumpto.php" file is OUTSIDE of your project.

If you are NOT trying to execute that file .. then consider unchecking  "Settings | PHP | Debug | Force break at first line when a script is outside the project"


Thank you I have been able to get rid of the breakpoints outside my project by unchecking both of the 'Force' checkboxes. I still am not able to hit a breakpoint in my project. The browser reports that I am running on http://localhost/moodle/mod/mediasite/search.php?course=1. PhpStorm has a breakpoint set at the first possible executable line in that file


But this breakpoint is never hit. I must still be doing something wrong.

Thank you.



Back to "Settings | PHP | Servers"

You do have "Use path mappings" checked (must have been done by that "missing mapping" initial dialog). Unchecking it should do the trick (otherwise IDE expects correct mappings.. which are currently not provided --- you do not need them if your project is located at the same place where website is served from).

If the above will not help -- try deleting that entry completely and try again.

BTW -- all files on screenshot are marked as read-only -- is that OK for you?


Thank you my breakpoints are now being hit. But it is still kind of a black box to me. How should the path mappings be setup so it will work without unchecking this setting?

Thank you.


How should the path mappings be setup so it will work without unchecking this setting?

In your case -- exactly the same as on left side -- that's why you do not need them :)

Like these (edited in ms paint):

You only need them when you do remote debugging (and remote path is different to local one) .. or when you use any sort of symlinks (actual symbolic links or junction points (windows only?)) -- even if it's for one file/folder.

Example: if you have project located at C:\projects\myproject but actual website is served from C:\websites\myproject, then (considering that all files being copied to website folder) you will need mappings as well. All because: xdebug works with real (resolved) paths .. and if it's differs to what IDE knows/works with (which works with files as is -- without resolving symlinks) then IDE cannot really match what file is to be debugged.


One last question. I install both the Chrome Jet Brains IDE Support and PHP Console extensions but I am not sure how to use them. Do you have any documentation?

Thanks again.



Don't know nothing about PHP Console extension (I mean -- I know what this is and how it can be used, but never used it (or plan to use it, for the moment) myself. The Firefox alternative has been around for a long time -- called FirePHP).

Chrome Jet Brains IDE Support is for LiveEdit functionality as well as JavaScript debug.



Please sign in to leave a comment.