Creating PHP Classes, Interfaces, and Traits
On this page:
PhpStorm supposes that the namespaces in your project are arranged in compliance with the PSR0 standard and enforces you to retain the folder structure and the namespace hierarchy in accordance with this standard when creating classes, interfaces, and traits.
When you specify the folder where the file that implements the new class will be stored, PhpStorm automatically updates the namespace for the class.
Creating PHP classes
- In the Project tool window, select the folder that corresponds to the namespace where you want a new class/interface/trait created and then choose on the context menu of the selection. The Create New PHP Class dialog box opens.
- In the Name text box, type the name of the class/interface/trait to be created. PhpStorm automatically fills in the specified name in the File Name field.
- Specify the namespace to create the class/interface/trait in. By default, the
Namespace field shows the namespace that corresponds to the folder from which the
class/interface/trait creation was invoked.
You can choose Global namespace from the drop-down list or change the namespace manually keeping mind that this may cause problems with loading as such namespace hierarchy will not meet the PSR0 standards.
- In the Kind drop-down list, specify what to create, the available options are:
- Choose the file extension from the drop-down list.