Configuring Folders Within a Content Root
Within a content root, PhpStorm can distinguish between the folders that contain source code, and the ones to be ignored while searching, parsing, watching and so on. To do so, you can mark any folder below a content root as a source folder, or as excluded so it becomes invisible for PhpStorm.
Within a content root, PhpStorm can distinguish between Source folders, Resource Root folders, Test Source code, and Excluded folders.
The folder marked as Source is the root folder for all the PHP namespaces in the current project.
Files under a folder marked as Resource Root can be referenced relative to this folder. Excluded folders are not involved in indexing and therefore they are ignored while searching, parsing, watching and so on.
To invoke this distinction, you can mark any folder below a content root as Source, Resource Root, Test, or Excluded.
The folders configuration that you define also regulates the behavior of the PhpStorm's Usage of internal entity inspection, which detects incorrect usages of the entities marked as
You can assign a folder to a category in two different ways:
Using the context menu of a folder in the Project tool window.
Mark directories under the content root
In the Directories page, click the desired content root. The directories under this content root are displayed as a tree view in the right-hand pane.
Select the directory you want to mark and do one of the following:
To have PhpStorm consider the contents of the selected folder as unit tests, click the Tests toolbar button or choose Test Sources from the context menu of the selection.
To have PhpStorm consider the selected folder as the root for namespaces used in your project, click the Sources toolbar button or choose Sources from the context menu of the selection.
Based on this setting, PhpStorm suggests the proper folder name when you want to create a new namespace under another parent namespace during creation or moving a PHP class, that is, when you are actually creating or moving a PHP class to a non-existing namespace under another parent namespace. If no Sources folder is specified, you will have to type the proper folder manually.
To have PhpStorm ignore the selected directory during indexing, parsing, code completion, and so on, click the Excluded toolbar button or choose Excluded from the context menu of the selection.
To enable PhpStorm to complete relative paths to resources under the selected folder, click the Resource Root toolbar button or choose Resource Root from the context menu of the selection.
Mark directories in the Project tool window
Right-click the desired directory in the Project Tool Window.
From the context menu, point to Mark Directory As node.
Choose Mark as <directory status>.
To return a folder to its regular status, you need to unmark it.
- On the Directories page of the Settings / Preferences Dialog, do any of the following:
Select the directory in the list of folders under the content root, and click :
Click the folder's status icon once more.
Choose the corresponding command from the context menu of the directory.
In the Project Tool Window, right-click the desired directory, point to Mark Directory As node, and then choose Unmark as <directory status>.
Internal entities handling
The PhpStorm's Usage of internal entity inspection detects incorrect usages of the entities that are marked with the
@internal annotation. Such entities should be internal to a package or a library:
The folders configuration that you define for your project regulates whether an entity is treated as internal or not by PhpStorm:
In a project without any Sources folders configured, no
@internalclasses' usages are marked.
@internalclass is located inside a configured Sources folder, the usages within the same sources folder are not marked. Usages outside this sources folder are marked.
@internalclass is located inside a library, all its usages outside libraries are marked.
Inside the Test Sources folder, no
@internalclasses' usages are marked.