<p>I point <code>File-&gt;Open Directory</code> at <code>craft/..</code>, and PhpStorm pick up everything for me. You probably have to set up path mappings to make debugging work properly, but PhpStorm will alert you to that and launch the mapping UI.</p>

<p>I have a sandbox Craft install running at <code>local.sandbox.dev</code> and I create a git repo in the <code>plugins</code> directory, and develop the plugin in there. That way I can have multiple plugins in this sandbox, all with different repos, whereas the Craft install itself is not version controlled. Makes it easy also to dump the entire installation and replace it whenever the database becomes too mangled.</p>

CC BY-SA 3.0
2015-08-03T00:59:42.613Z
You got me started, and I followed the instructions here: http://manovotny.com/setup-phpstorm-xdebug-mamp-debugging/ and debugger is working as well.
Marion Newlevant
CC BY-SA 3.0
2015-07-31T10:21:41.270Z
2015-07-31T10:21:41.270Z
megatrond
<p>I've never actually used the PhpStorm new project wizard, but I believe what it's asking is:</p>

<ol>
<li>Are your source repo files <em>also</em> where your web server is pointing when you go to <code>yourdomain.com</code>?</li>
</ol>

<p>OR</p>

<ol start="2">
<li>Do you have a source repo directory and a separate sites directory where your web server is pointing for <code>yourdomain.com</code>? In this scenario you'd need to copy over the source repo files to the site directory manually or setup a way to sync them.</li>
</ol>

<p>A common plugin development scenario is more of a modification of the 2nd option.  You'll have a source repo with your plugin files in it and a separate Craft installation that <code>yourdomain.com</code> points to, but from the <code>craft/plugins</code> folder your make a symlink to your plugin repo so that you can make changes directly in the repo and immediately test them on the site.</p>

<p>But I wouldn't bother using the new project wizard at all.  Just open the source repo using <code>File-&gt;Open Directory</code> and setup everything up externally.</p>

CC BY-SA 3.0
2015-07-31T06:17:05.780Z
I have the plugin source in `craft/plugins/myplugin`. I think I am confused about the source repo vs the webroot.  My webserver is pointing to `public`, but craft is in `../craft`. Do I point `File->Open Directory` at `craft`? at `public`? at `craft/..`?
Marion Newlevant
CC BY-SA 3.0
2015-07-31T16:19:13.460Z
Sorry, when I say source repo, I'm assuming something like a GitHub source repo, where the plugin is under source control.  Maybe you've got the whole site under source control and you're including the plugin in that?
Brad Bell
CC BY-SA 3.0
2015-07-31T17:46:41.623Z
I'm not even worrying about the source control part of the puzzle yet.
Marion Newlevant
CC BY-SA 3.0
2015-07-31T03:34:37.777Z
2015-07-31T03:34:37.777Z
Brad Bell
<p>Can someone explain how to set up PhpStorm so that I can use it to develop/debug a plugin? I have</p>

<ul>
<li>local webserver set up</li>
<li>craft files in the usual place above the webroot</li>
</ul>

<p>The new project wizard gives me a choice between <strong>"Web server is installed locally, source files are located under its document root"</strong> and <strong>"Web server is installed locally, source files are located elsewhere locally. (Source files are copied to project root, then synchronized with server when necessary.)"</strong> Neither of which seems quite right.</p>

<p>Directory structure:</p>

<ul>
<li>craft

<ul>
<li>app</li>
<li>plugins

<ul>
<li>myplugin</li>
</ul></li>
</ul></li>
<li>public &lt;== this is webroot

<ul>
<li>.htaccess</li>
<li>index.php</li>
</ul></li>
</ul>

<plugin-development><debugging>
How do I set up PhpStorm for plugin development
# How do I set up PhpStorm for plugin development

(Asked by: username_0 on 2015-07-30)

Can someone explain how to set up PhpStorm so that I can use it to develop/debug a plugin? I have

* local webserver set up
* craft files in the usual place above the webroot

The new project wizard gives me a choice between **"Web server is installed locally, source files are located under its document root"** and **"Web server is installed locally, source files are located elsewhere locally. (Source files are copied to project root, then synchronized with server when necessary.)"** Neither of which seems quite right.

Directory structure:

* craft
  + app
  + plugins
    - myplugin
* public <== this is webroot
  + .htaccess
  + index.php

**Tags:** plugin-development, debugging

---

## 2 answers

### Answer by username_1 on 2015-07-31. Score: 3 | Accepted answer

I point `File->Open Directory` at `craft/..`, and PhpStorm pick up everything for me. You probably have to set up path mappings to make debugging work properly, but PhpStorm will alert you to that and launch the mapping UI.

I have a sandbox Craft install running at `local.sandbox.dev` and I create a git repo in the `plugins` directory, and develop the plugin in there. That way I can have multiple plugins in this sandbox, all with different repos, whereas the Craft install itself is not version controlled. Makes it easy also to dump the entire installation and replace it whenever the database becomes too mangled.

> **Comments:**
> **username_0**: You got me started, and I followed the instructions here: http://manovotny.com/setup-phpstorm-xdebug-mamp-debugging/ and debugger is working as well.  

---

### Answer by username_2 on 2015-07-31. Score: 1

I've never actually used the PhpStorm new project wizard, but I believe what it's asking is:

1. Are your source repo files *also* where your web server is pointing when you go to `yourdomain.com`?

OR

2. Do you have a source repo directory and a separate sites directory where your web server is pointing for `yourdomain.com`? In this scenario you'd need to copy over the source repo files to the site directory manually or setup a way to sync them.

A common plugin development scenario is more of a modification of the 2nd option. You'll have a source repo with your plugin files in it and a separate Craft installation that `yourdomain.com` points to, but from the `craft/plugins` folder your make a symlink to your plugin repo so that you can make changes directly in the repo and immediately test them on the site.

But I wouldn't bother using the new project wizard at all. Just open the source repo using `File->Open Directory` and setup everything up externally.

> **Comments:**
> **username_0**: I have the plugin source in `craft/plugins/myplugin`. I think I am confused about the source repo vs the webroot.  My webserver is pointing to `public`, but craft is in `../craft`. Do I point `File->Open Directory` at `craft`? at `public`? at `craft/..`?  
> **username_2**: Sorry, when I say source repo, I'm assuming something like a GitHub source repo, where the plugin is under source control.  Maybe you've got the whole site under source control and you're including the plugin in that?  
> **username_0**: I'm not even worrying about the source control part of the puzzle yet.  

---

