Debugging a Wordpress plugin with PhpStorm

Hi,

Downloaded PhpStorm today, to try to use it for work on a Wordpress plugin which is already up and running.  The resulting site is deployed on my local machine.  Using Windows XP Pro.

If I create a new project in the suggested "My documents" folder, and set its External Library to be the root Wordpress folder, then I get a nice indented listing under External Library, which includes my plugin files, and I can double-click them to open one. However, as someone else has noted, being an External Library this means that my javascript files in there can't be edited (and arguably it's technically a bug that my PHP ones can?).  At least in this configuration the PHP is interpreted correctly.

If I now declare a Default Content folder (which is my own plugin folder, within wp-content\plugins), two bad things happen:

  • the indented list under External Library vanishes
  • the Wordpress environment is longer available, which means that when I open my main PHP plugin module I get a raft of parsing errors.


What I want to have is a project where my own plugin files (which sit, as they must, within the overall Wordpress framework) are available for editing, and where they are interpreted correctly in relation to the Wordpress environment.

I'm presumably doing (or not doing) something really dumb, but I can't see it.  Any help gratefully received ...

Richard

3 comments
Comment actions Permalink

Andriy,

Thanks for these links. I did do a web search before posting to the list, and found both of these. One wasn't relevant to my situation (being LAMP-oriented), and I tried to follow the other, but it resulted in the situation I described in my post, i.e. incorrect parsing of my PHP.

Now that I understand the situation a bit better, I can see that the project root has to be the Wordpress folder (rather than my plugin folder), because that is the context from which a web server will try to interpret the PHP.  However, I still find that if I select the Wordpress folder as the project root, I get parsing errors.  If I select the Wordpress folder as an external library, I don't.  So maybe this is a PhpStorm bug?

Thanks,

Richard

0
Comment actions Permalink
However, I still find that if I select the Wordpress folder as the project root, I get parsing errors.  If I select the Wordpress folder as an external library, I don't.  So maybe this is a PhpStorm bug?

Quite unlikely.

When code in under External Libraries it is not getting checking for syntax errors (it's 3rd party code that is not really meant to be edited -- it is included for references only).

Would be good if you provide a sample project with such installation that would illustrate such problem (include all necessary files -- e.g. default/blank wordpress site with whatever related files you think are important). From my experience (last time I worked with WordPress was around 3-4 month ago or so -- simple edit few things, nothing big at all) it worked OK. There are some warnings ... but that's purely because of the way how WordPress is written (global variables that declared in completely different places with no type-hints and similar).

P.S.
Have you seen this video? Title sounds relevant: http://www.youtube.com/watch?v=nt85dnx0V8Y

0

Please sign in to leave a comment.