1

In The PhpStorm you can search to text in all files in the whole project -- just click Schift+F. And you can set the filename mask there, like *.php

The test/phpunit folder is located in the project as well and is indexed for search. This is good and useful.

But sometimes you need to search in source code only, not in the test files.

It means that you should not disable those files from search index -- you need them.

PHPStorm exclude files by mask from indexing

WebStorm/PhpStorm exclude file from search everywhere

You just need some ability to filter them out sometimes.

I supposed to use the mask like "*[~^test]*.php" but it seems is not supported.

Any idea?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Eugene Kaurov
  • 2,356
  • 28
  • 39
  • 2
    Considering that the test files woudl *normally* be named like `SomethingTest.php` .. then exclusion mask would be `!*Test.php`. Question is -- how often do you need to execute such search? If often -- I would suggest to setup custom Scope (that will exclude all unwanted locations .. or opposite: include only wanted files/folders) and use it there. 1) https://www.jetbrains.com/help/phpstorm/settings-scopes.htm 2) https://www.jetbrains.com/help/phpstorm/finding-and-replacing-text-in-project.html – LazyOne May 11 '20 at 09:42
  • @LazyOne, wow, that's already an intelligent solution! Is there the ability to combine scopes? eg. *.php; !*Test.php otherwise the search would be in all even image files, not only PHP ones. The first link is broken. – Eugene Kaurov Aug 24 '20 at 16:30
  • Somehow missed `l` letter at the end of that URL: https://www.jetbrains.com/help/phpstorm/settings-scopes.html & https://www.jetbrains.com/help/phpstorm/configuring-scopes-and-file-colors.html – LazyOne Aug 24 '20 at 16:34
  • 1
    *"Is there the ability to combine scopes? eg. *.php; !*Test.php..."* Yes, it's possible in File Mask field of Find in Path as well: `*.php,!*test.php` (just use coma as separator) -- will search in all .php file excluding *Test.php. But overall *I think* that proper Scope is more suitable (e.g. you can exclude some subfolders .. or include other files as well). – LazyOne Aug 26 '20 at 23:05
  • @LazyOne Thank you very much. Would you like to write an official answer so I can accept it or do you want me to write it? – Eugene Kaurov Sep 07 '20 at 10:12

1 Answers1

4

Considering that the test files would normally be named like SomethingTest.php .. then exclusion mask would be !*Test.php.

To combine multiple extensions just list them using comma ,, e.g. *.php,!*test.php (search in .php files only but excluding test files)


P.S. If you need to make such search often, it may be more convenient to create and use custom Scope (it can also be used in many other places: Navigate To File/Class/Symbol; Project View panel, File Watchers etc.)

Scope is more flexible as it allows to select specific folders and have more complex include or exclude patterns in general (as it can work with folder names as well).

LazyOne
  • 158,824
  • 45
  • 388
  • 391