PhpStorm 2023.2 Help

Content root

In PhpStorm, content is a collection of files with which you are currently working, possibly organized in a hierarchy of subfolders. The folder that is the highest in this hierarchy is called the content root folder or content root (shown as the Content root icon) for short. A project has at least one content root folder, which by default is the project folder itself.

Having several content roots enables you to work with files from several directories that do not have a common immediate parent. This is helpful when you use static contents, for example, icons. You can just save them all in a folder and then specify this folder as an extra content root in several projects.

Content root types

By default, all the files in a content root folder are involved in indexing, searching, parsing, code completion, and so on. To change this status, folders within a content root can be assigned to the following categories:

  • Source roots (or source folders; shown as the Source root icon).

    This is 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. For more information, refer to Configure PHP namespaces in a project.

  • Test source roots (or test source folders; shown as the Tests root icon).

  • Resource roots or resource folders; shown as the Resources root icon.

    By assigning a folder to this category, you tell PhpStorm that files in it and in its subfolders can be referenced relative to this folder instead of specifying full paths to them.

  • Excluded roots (shown as the Excluded root icon) are ones that PhpStorm "almost ignores".

    These roots contain files and folders ignored by PhpStorm when indexing, searching, parsing, watching and so on.

    Excluded roots are not visible to PhpStorm. Usually, one would like to exclude temporary build folders, generated output, logs, and other project output. Excluding the unnecessary paths is a good way to significantly improve performance.

  • Library roots (shown as the Library root icon) are basically excluded roots that contain libraries as PHP include paths and are therefore indexed. For more information, refer to PHP library roots.

Last modified: 23 March 2023