<p>I can confirm that Win8.1 + PHPStorm + xDebug and plugin code works fine.</p>

<p>Are you symlink'ing (using mklink in Windows) to your plugin code by chance? xDebug won't follow symlink's by default and at least in PHPStorm, you have to explicitly setup the path mapping in your project's settings to tell PHPStorm/xDebug where the <em>actual</em> paths to your symlink'ed files live.</p>

CC BY-SA 3.0
2014-09-06T23:33:44.800Z
i dont think i'm doing that, certainly not intentionally. i wonder if its eclipse. good to know phpstorm will work
Andrew Wisener
CC BY-SA 3.0
2014-09-06T17:18:07.410Z
2014-09-06T22:42:45.107Z
2014-09-06T22:42:45.107Z
Brad Bell
<p>PHPStorm debugs fine. So the solution is to use that for debugging Craft sites</p>

CC BY-SA 3.0
2015-11-26T21:06:32.467Z
I'm using IntelliJ and can confirm debugging works on the index.php however it never comes to the breakpoint of my Plugin. How did you get this to work for PHPStorm since they are "almost" the same IDE's Thanks in advance!
IColorfield
CC BY-SA 3.0
2015-11-26T22:21:16.433Z
@IColorfield: Probably worth asking as a brand new question... this is a very old thread. Feel free to link back to this thread for reference.
Lindsey D
CC BY-SA 3.0
2014-09-09T01:32:39.293Z
2014-09-09T01:32:39.293Z
Andrew Wisener
<p>Andrew, you could always use Whoops. <a href="https://github.com/filp/whoops" rel="nofollow">https://github.com/filp/whoops</a>. </p>

<p>What you could do is just install Whoops through composer in your plugin directory (here is an example of my composer.json file (<a href="http://d.pr/i/trWp" rel="nofollow">http://d.pr/i/trWp</a>). </p>

<p>Then you could include this within your plugin:</p>

<pre><code>include(CRAFT_BASE_PATH . 'plugins/(your directory)/vendor/autoload.php');
</code></pre>

<p>That's basically it. Here is an example of an exception thrown within my plugin with a full stack trace. </p>

<p><a href="http://d.pr/i/Ar8v" rel="nofollow">http://d.pr/i/Ar8v</a></p>

CC BY-SA 3.0
2014-09-06T23:32:15.640Z
hey matt, that looks good. it seems to me that php coders much prefer dumping to the screen rather than debugging. I come from a M$ background, in visual studio .net  coder not debugging is unheard of.
Andrew Wisener
CC BY-SA 3.0
2014-09-06T23:35:40.600Z
Come from a .NET background as well. Give PHPStorm a go. It's by far the closest thing you'll get to VS in the PHP world.
Brad Bell
CC BY-SA 3.0
2014-09-07T04:01:53.180Z
I'll second that. PHPStorm is by far the best IDE for PHP IMO. I use that along with Xdebug as well, just not for everything. I don't know the huge difference in "debugging" from the IDE and outputting most of what the IDE debugger gives you in the browser. I know with PHP you don't have to compile everything like .NET so it's probably more similar than you think. But I am not from the .NET world so I really don't know. Hope PHPStorm works well for you!
Matt Green
CC BY-SA 3.0
2014-09-06T04:32:11.603Z
2014-09-06T04:32:11.603Z
Matt Green
<p>I'm new to php development, so I'm probably doing something silly...</p>

<p>I have setup Craft running in a Vagrant VM on Windows 8. I am using XDebug and Eclipse as my IDE. It all works beautifully! However I cannot debug any of my plugin code. I can step into the Craft code but it never breaks on any plugin actions. I suspect its something to do with the way the Craft code is calling the actions, it looks like it is using some sort of reflection to call the methods of the plugin class. Can anyone help? Is there a way to debug plugin code? Or perhaps a better IDE if it is Eclipse that has this limitation?</p>

CC BY-SA 3.0
2014-09-05T04:12:38.243Z
Could this be a routing issue? Are you using {siteUrl} + config.php to correct for the right site url? What kinds of errors are you seeing?
Adam McCombs
CC BY-SA 3.0
2014-09-05T11:10:11.870Z
no errors, the debugger simply doesn't break in any plugin code. The code runs but the debugger doesn't work. non plugin craft code debugs fine.
Andrew Wisener
CC BY-SA 3.0
2014-09-06T03:10:53.023Z
Adam, just rereading your comment, what do you mean about using config.php to correct for right site url? I have not come across that.
Andrew Wisener
CC BY-SA 3.0
2014-09-06T20:35:17.043Z
Hey Andrew - in general.php you can set dynamic urls. So in your db, you only use {siteUrl} but you can have multiple setups for your different environments.

if ($_SERVER['SERVER_NAME'] == 'local.site')
{
    return array(
        'omitScriptNameInUrls' => true,
        'devMode' => true,
        'environmentVariables' => array(
            'siteUrl'        => 'http://local.site/',
            'fileSystemPath' => '',
        )
    );
}
Adam McCombs
CC BY-SA 3.0
2014-09-06T20:36:59.137Z
That is to say if this isn't set correctly or your Craft install is still pointing to your localhost vs. the server it's living on, it could cause all sorts of problems.
Adam McCombs
<debugging>
Debugging Craft plugin actions
# Debugging Craft plugin actions

(Asked by: username_0 on 2014-09-05)

I'm new to php development, so I'm probably doing something silly...

I have setup Craft running in a Vagrant VM on Windows 8. I am using XDebug and Eclipse as my IDE. It all works beautifully! However I cannot debug any of my plugin code. I can step into the Craft code but it never breaks on any plugin actions. I suspect its something to do with the way the Craft code is calling the actions, it looks like it is using some sort of reflection to call the methods of the plugin class. Can anyone help? Is there a way to debug plugin code? Or perhaps a better IDE if it is Eclipse that has this limitation?

**Tags:** debugging
> **Comments:**
> **username_1**: Could this be a routing issue? Are you using {siteUrl} + config.php to correct for the right site url? What kinds of errors are you seeing?  
> **username_0**: no errors, the debugger simply doesn't break in any plugin code. The code runs but the debugger doesn't work. non plugin craft code debugs fine.  
> **username_0**: Adam, just rereading your comment, what do you mean about using config.php to correct for right site url? I have not come across that.  
> **username_1**: Hey Andrew - in general.php you can set dynamic urls. So in your db, you only use {siteUrl} but you can have multiple setups for your different environments.  if ($_SERVER['SERVER_NAME'] == 'local.site') {     return array(         'omitScriptNameInUrls' => true,         'devMode' => true,         'environmentVariables' => array(             'siteUrl'        => 'http://local.site/',             'fileSystemPath' => '',         )     ); }  
> **username_1**: That is to say if this isn't set correctly or your Craft install is still pointing to your localhost vs. the server it's living on, it could cause all sorts of problems.  

---

## 3 answers

### Answer by username_2 on 2014-09-06. Score: 2

I can confirm that Win8.1 + PHPStorm + xDebug and plugin code works fine.

Are you symlink'ing (using mklink in Windows) to your plugin code by chance? xDebug won't follow symlink's by default and at least in PHPStorm, you have to explicitly setup the path mapping in your project's settings to tell PHPStorm/xDebug where the *actual* paths to your symlink'ed files live.

> **Comments:**
> **username_0**: i dont think i'm doing that, certainly not intentionally. i wonder if its eclipse. good to know phpstorm will work  

---

### Answer by username_0 on 2014-09-09. Score: 1

PHPStorm debugs fine. So the solution is to use that for debugging Craft sites

> **Comments:**
> **username_3**: I'm using IntelliJ and can confirm debugging works on the index.php however it never comes to the breakpoint of my Plugin. How did you get this to work for PHPStorm since they are "almost" the same IDE's Thanks in advance!  
> **username_4**: @IColorfield: Probably worth asking as a brand new question... this is a very old thread. Feel free to link back to this thread for reference.  

---

### Answer by username_5 on 2014-09-06. Score: 1

Andrew, you could always use Whoops. https://github.com/filp/whoops. 
What you could do is just install Whoops through composer in your plugin directory (here is an example of my composer.json file (http://d.pr/i/trWp). 
Then you could include this within your plugin:
include(CRAFT_BASE_PATH . 'plugins/(your directory)/vendor/autoload.php');

That's basically it. Here is an example of an exception thrown within my plugin with a full stack trace. 
http://d.pr/i/Ar8v

> **Comments:**
> **username_0**: hey matt, that looks good. it seems to me that php coders much prefer dumping to the screen rather than debugging. I come from a M$ background, in visual studio .net  coder not debugging is unheard of.  
> **username_2**: Come from a .NET background as well. Give PHPStorm a go. It's by far the closest thing you'll get to VS in the PHP world.  
> **username_5**: I'll second that. PHPStorm is by far the best IDE for PHP IMO. I use that along with Xdebug as well, just not for everything. I don't know the huge difference in "debugging" from the IDE and outputting most of what the IDE debugger gives you in the browser. I know with PHP you don't have to compile everything like .NET so it's probably more similar than you think. But I am not from the .NET world so I really don't know. Hope PHPStorm works well for you!  

---

