Exclude a folder without hiding it

Hi All,

Currently I'm having a challenge with code inspections I hope someone here can help me with. I am using a home grown php parser to take a php file, make some modifications, and save the newly modified file in a tmp directory. When my code runs it auto loades from the tmp directory using the same class and namespace names. Unfortunatley this makes PHPStorm think there is a problem with the namespaces in my normal code.

I've done some searching around and found two methods people have used to "exclude" files in their poject.

  1. Use "mark as Excluded"
  2. Use scopes
  3. Exclude and then include the folder as an external lib


The problem with Excluding a folder is that the folder disappears from the project entirely. I am unable to view it without going into my project settings. This is problematic when I want to quickly look how my "compiled" classes are doing, or when I want to look through the code to debug any issues. Excluding works great for fixing the namespace error, but isn't a viable solution since I can't easily view my generated files.

With scopes, I'm able to create a different "view" of the temp files, and even modify the inspections on them, but I see no way to tell phpstorm to just ignore those files. I still get the namespace errors.

Option 3 seems like it may work, but once I include the folder the errors pop back up again.

So, I'm at a loss. Is there any way to tell phpstorm to ignore / exclude a folder but still make it (and its files) easily accessible?

Thanks for any help you can provide!

-Jeff

0
4 comments

Hi Jeff,

1) You can mark each file as Text File (In Project View, right click, Mark as Plain Text). This needs to be done manually for every "problematic" file

2) Give those files separate/double extension (e.g. FileName.compiled.php ... or FileName.phpc) -- then you will be able to assign *.compiled.php (or *.phpc) pattern to Text Files entry in "Settings | File Types" (such files will be treated as plain text, so no indexing, code analysis, syntax highlighting etc). This, of course, requires changing your code a bit (autoloader part), but changes are very minimal.

Other than that: wait until the following ticket will be implemented -- this will allow to do approach #1 in single click: http://youtrack.jetbrains.com/issue/IDEA-97846

P.S.
There are other tickets for similar kind of functionality (different ideas behind) .. but I cant find them right now

0
Avatar
Permanently deleted user

Hi Andriy,

Your solution is so painfully obvious I feel silly now. Since I'm already "compiling" the files, I can simply make the extension something that will be ignored by PHPStorm.. something like .comp or .compiled or something. Sometimes it just takes someone outside of the problem to point out the obvious.

Thanks!

-Jeff

0

Solution: toggle the “Show excluded files” setting

Approach 1: 

  1. open the Project Tool Window (CMD+1 / ALT+1)
  2. at the top right, click on the three vertical dots [ ⋮ ], should be the 2nd icon from the right

  3. hover “Appearance”
  4. check “Excluded Files”

Approach 2:

  1. press SHIFT twice
  2. (optional) hit TAB until you reach the “Actions” tab (should be 4×)
  3. type “excluded”
  4. navigate to “Project View Options | Appearance: Show Excluded Files”
  5. enable it
  6.  

     

0

note: you might need to check “Include disabled actions” in the top right corner of the search modal (see screenshot at the end)

0

Please sign in to leave a comment.