What and Why: "For WordPress containing plugins inside it's better to add whole WordPress to project"

In the PhpStorm documentation one is instructed to create a project using only the folder containing the project files and the WP install is represented as a separate entity one includes in the project resources.

 

I install VVV at a location like this:

C:\vvv

I then point PhpStorm to the WordPress install (Settings --> Languages & Frameworks --> PHP --> Frameworks):

C:\vvv\www\wordpress-one\public_html

I also tell PhpStorm that the project I want to work on resides in:

C:\vvv\www\wordpress-one\public_html\wp-content\themes\my-theme

And I add the WP install path as instructed as an Include Path (Settings --> Languages & Frameworks --> PHP --> Include Path --> +) which points to:

C:\vvv\www\wordpress-one\public_html

When I exit out of the settings menu (e.g. all settings are applied) a bubble pops up informing me:

"WordPress Support
For WordPress containing plugins inside it's better to add whole WordPress to project."

Can someone help me understand exactly what this means and why?

It sounds to me like it is saying:

If your project is inside the install of WordPress you will use as your PhpStorm reference install (e.g., what it pulls code completion from, etc.) then you should set your project up to be the entire reference install rather than adding it as an include.

Okay. But why?

The difficulty is that VVV doesn't "support" (officially) the use of code outside of the VVV folders - e.g., I can't easily have my theme code at: C:\code\my-theme, VVV wants it inside the WP install.

Any suggestions on getting around this? Maybe I could create another WP install (just download and extract the files) that PhpStorm would use as its reference and then it wouldn't prompt me like this?

0
2 comments

> I also tell PhpStorm that the project I want to work on resides in:

Could you please clarify where/how?

 

> Can someone help me understand exactly what this means and why?

Basically it's: if we see a project as a plugin inside WordPress installation -  we suggest to re-add whole installation as content root or to add WP installation as included path.

In other words it's better to have a project with a root at

C:\vvv\www\wordpress-one\public_html\

instead of

C:\vvv\www\wordpress-one\public_html\wp-content\themes\my-theme

 

I would suggest to simply close your current project, then open PhpStorm, select Open:

then browse to C:\vvv\www\wordpress-one\public_html and hit Open.

This would open your WP installation as a wordpress project. You would receive a prompt suggesting to enable WP integration after an opening.

 

 

0

Thanks Dmitry for the explanation.

What I don't understand is why it is better to have the entire installation as the project than the specific plugin/theme one is working on.

For example, if I want to search through the theme I'm working on I can do this by selecting the root node of my project and Ctrl+Shift+F if my project is scoped to the theme only.

But if I use the main installation folder for WP, now I have to be careful to navigate to the theme folder I'm actually working with, otherwise I'll end up running the find against the entire WP install.

This is a pretty minor annoyance...bigger ones are when JetBrains attempts to refactor code outside of the theme. For example, if one has a class screen-reader-text that is also a class in WP itself and one attempts to refactor the class in one's theme, JetBrains will attempt to refactor not only your theme's usage but also all instances in WP core - not at all what I'm looking for. :)

0

Please sign in to leave a comment.