Features Releases

UML Diagrams in PhpStorm 2017.2

Unified Modelling Language can be used to draw out the relationships between classes, abstract classes, and interfaces, to help you to visualize exactly how your classes interact and are related. PhpStorm has tools that can help you to create these diagrams, and manipulate your code from within the chart.

To create a UML diagram, use the context menu (right click) on the class name (or even a folder of classes or the whole project) in the project pane, and select Diagrams | Show Diagram…


This shows how the `IndexController` extends the `AbstractActionController` which extends the `AbstractController`, which implements three interfaces. This can be very useful to visualize the object hierarchy, but you can manipulate your code from within the diagram view, as well as modify just the diagram.

You can add notes to the chart from the context menu New… | Note which can be useful for explaining what each abstraction is for. Pressing allows you to Collapse nodes, and pressing E allows you to expand nodes by their namespace. This is useful for navigating around the tree, as expanding nodes will add classes to the diagram if they aren’t already there. You can also add classes to the diagram by pressing Space.

You can usefully show and hide methods, properties, constants, and the constructor either from the context menu or by using the diagram menu at the top of the diagram. Showing methods and properties is particularly useful as it allows you to see exactly which entity a method or property is implemented in.


You can also refactor the entity from the context menu – the whole Refactor menu is available for each object, so, for example, you can rename an interface by right-clicking on it and selecting Refactor | Rename. 

New in PhpStorm 2017.2 is the chance to add code to your entity by using the New… | Create New Field or Create New Method context menu items. The UML diagram can be very handy for having a good overview of your application, and the new refactoring abilities from within the chart will hopefully make it an even more useful tool. You can learn more about UML diagrams from this tutorial in the documentation.

– Gary & The PhpStorm Team

image description