PhpStorm 2023.1 Help

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 distinguish different types of folders, mark any folder below a content root as a source folder or as excluded.

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 in the folder that is 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 other operations.

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 @internal.

Marking directories

You can assign a folder to a category in two different ways:

Mark directories under the content root

  1. In the Settings dialog (Ctrl+Alt+S), select Directories.

  2. On the Directories page, click the desired content root. Directories under this content root are displayed as a tree view in the right-hand pane.

  3. Select the directory and use its context menu or the Mark as toolbar to mark it as one of the following:

    • Test root folder Tests: PhpStorm considers the contents of a Tests folder to be unit tests.

    • Sources root Sources: PhpStorm considers a Sources folder to be the root for namespaces used in your project.

      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.

      Appointing a Sources folder is not mandatory but this helps you keep your project structure in compliance with the PSR0 and PSR4 standards. See Configure PHP namespaces in a project for details.

    • Excluded root Excluded: PhpStorm ignores Excluded folders during indexing, parsing, code completion, and so on.

      A specific case of excluded folders is the Library root icon Library roots. Library folders are excluded roots that contain libraries as PHP include paths and are therefore indexed. For details, see PHP library roots.

    • Resource root Resource Root: PhpStorm completes relative paths to resources under the Resource Root folder.


Mark directories in the Project tool window

  1. Right-click the desired directory in the Project tool window.

  2. From the context menu, point to Mark Directory As node.

  3. Choose Mark as <directory status>.

Unmarking directories

To return a folder to its regular status, you need to unmark it.

  • On the Directories page of the Settings, do any of the following:

    • Select the directory in the list of folders under the content root, and click Unmark source root:

      Unmark source root
    • 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.

Internal entity usage

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 Sources root folders configured, no @internal classes' usages are marked.

  • If an @internal class is located inside a configured Sources Sources root folder, the usages within the same sources folder are not marked. Usages outside this sources folder are marked.

  • If an @internal class is located inside a library, all its usages outside libraries are marked.

  • Inside the Test Sources Test root folder folder, no @internal classes' usages are marked.

Last modified: 01 June 2023