4

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
3

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.

| improve this answer | |
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

  1. 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.

| improve this answer | |
  • 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 Jul 31 '15 at 6:17
  • 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 Jul 31 '15 at 16:19
  • I'm not even worrying about the source control part of the puzzle yet. – Marion Newlevant Jul 31 '15 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.