ConfusedAmish
ConfusedAmish

Reputation: 291

Adding file to project which is outside of the project directory

I have a following root structure

dir1
dir2
index_dir
dir3
...
index.php

I wanna have a project in phpStorm (7.1.3) so that I see only index_dir and index.php

the problem is that if I create a new project via "Open directory" I will have only index_dir in my project. I would like to add the file index.php to that project and not every other directory. How can I do that. It's driving me nuts.

Upvotes: 9

Views: 9352

Answers (3)

Greg Bell
Greg Bell

Reputation: 2219

Recent versions of PHPStorm (circa 2018+) support multiple "content roots" which allow you to point to project files in different hierarchies.

In the Settings/Preferences dialog (Ctrl+Alt+S), click Directories. The Directories page opens.

To add a content root, click click Add Content Root in the right-hand pane and then select the required folder in the dialog that opens.

Reference: https://www.jetbrains.com/help/webstorm/configuring-project-structure.html#adding_content_root

Upvotes: 7

lancemonotone
lancemonotone

Reputation: 135

You could add a custom scope to your overall PS project.

For instance, I am working on an app called Quicklinks, and I only need a subset of the files in my overall WordPress install. I only want to see files with the word quicklinks in the file or directory name. To do this, I set up the following scope pattern in Settings | Appearance & Behavior | Scopes:

file:*quicklinks*/

This looks for any file or directory anywhere in my overall project containing the string quicklinks in its name.

Screenshot

In the OP's case, a scope with this pattern should work:

file:index*/

Beware that empty directories may not be included.

Upvotes: 0

DarkMukke
DarkMukke

Reputation: 2489

You can always setup an include path to a lower level directory but this will not work if you project is in the directory of you external library / included path (endless loop)

PhpStorm Add include path

The way you suggest it can just not be done

EDIT :

Although you cannot hide those other directories, you can ignore them

PhpStorm Ignore directories

Ignored directories will not be indexed

EDIT 2017 : In the later versions of PHPStorm, eg v2017.1 and later you can now open multiple projects int he same window, this is by far the best solution you will ever get.

Upvotes: 10

Related Questions