Fine‑Tuning PhpStorm: How to Use Directory Markings to Keep Your IDE Fast and Accurate
Set up PhpStorm’s directory markings to balance indexing speed and code intelligence. Learn how to exclude vendor, mark tests, and keep your IDE fast.
25 Sept 2026, 22:16 UTC

Why Directory Markings Matter
When a PHP project grows beyond a few hundred files, PhpStorm’s index can take minutes to build and may consume gigabytes of RAM. The IDE uses the index to power code completion, navigation, and inspections. If the index includes every file in a monorepo—including third‑party libraries, generated code, or test fixtures—those features become sluggish and sometimes produce false positives.
PhpStorm lets you tell the indexer which directories belong to production code, which are tests, and which should be ignored outright. The four markers available in Settings | Project Structure are:
- Sources – treated as main application code.
- Tests – treated as test code; inspections can be scoped separately.
- Resource root – files that are read at runtime (templates, configs).
- Excluded – removed from the index entirely.
How to Configure a Directory
- Open
Settings | Project: your‑project | Project Structure(orCtrl+Alt+Shift+S). - Select the folder in the tree on the left.
- In the toolbar above the tree, click the
Sources,Tests,Resources, orExcludedbutton. - PhpStorm will refresh the index for the affected scope; you’ll see a “Reindexing” notification in the status bar.
All changes are written to .idea/modules.xml and .idea/misc.xml, so if you commit the .idea folder, teammates will inherit the same markings.
Concrete Example: Excluding vendor but Still Resolving Composer Packages
Most projects keep third‑party libraries in vendor. Marking it as Excluded removes its files from the index, cutting memory usage. However, PhpStorm still needs to resolve classes from those libraries for autocompletion and navigation. The solution is to add vendor as a library root rather than a source root.
File | Project Structure | Libraries
Add | Java | vendor
Select the folder containing your Composer packages.
After adding the library, the IDE will treat the classes inside vendor as external dependencies: you’ll still get completion for them, but the files themselves won’t be indexed for local navigation or inspections.
Trade‑Offs and Pitfalls
- Too many Excluded folders – If you exclude directories that contain code you need to navigate to, PhpStorm will show “Class not found” or “Unresolved reference” errors because it can no longer find the symbols. Test your configuration by opening a file inside an excluded folder and trying to navigate to a class it defines.
- Resource roots vs. Sources – Marking a directory as a resource root means PhpStorm will treat its files as non‑code assets. If the directory actually contains PHP files you want to edit, mark it as a source instead.
- Version control – Committing the
.ideafolder shares the markings, which is convenient, but it can also expose absolute paths unique to a developer’s machine. If you prefer not to share, commit only themodules.xmlfile or usegitignorefor machine‑specific files. - Reindexing spikes – Changing markings triggers a reindex of the affected scope. In a 100‑kB monorepo, this may cause a noticeable CPU and memory spike for a few minutes. Plan such changes during low‑traffic periods.
Practical Checklist Before You Commit
- Verify that excluded directories no longer appear in
Navigate | FileorNavigate | Symbol. - Open a file in an excluded folder and press
Ctrl+Clickon a class name; it should be a no‑op. - Check the status bar for “Reindexing” after each change.
- Inspect
.idea/modules.xmlto confirm the expectedsourceFolderentries andexcludedtags. - Run a quick test:
phpunitorphp-cs-fixershould still find all test files even if thetestsfolder is marked asTests.
Actionable Takeaway
Use directory markings to keep PhpStorm responsive without sacrificing code intelligence. Mark production code as Sources, tests as Tests, runtime assets as Resource root, and third‑party or generated code as Excluded (but add it as a library if you need autocompletion). Test the configuration by navigating into the folder and watching the status bar. Once satisfied, commit the .idea/modules.xml file so your teammates share the same performance‑friendly setup.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.