'PhpStorm and PSR-12, how can I add it as default coding style?

PSR-12 is an extension of PSR-2, and therefore also an extension of PSR-1. The basis of PSR-12 is PSR-2 and therefore a list of differences is provided below to assist with migration but it should be considered as an independent specification.

From the php-fig site. Long story short, while not mandatory, it covers more code cases than PSR-2.

I'd like to use it in PhpStorm. Unfortunately, by default, storm doesn't offer this option. At predefined styles you have a fairly comprehensive list, but not comprehensive enough.

enter image description here

Of course, I can always define the style myself doing it by hand, but that doesn't strike me as a good idea. Mostly because I WILL miss something and if there are any updates to the PSR I can't easily update it. Not to mention I can't share it properly with my team. Except maybe exporting my .idea folder.

I googled around for a plugin or something of that sort but came up empty handed.



Solution 1:[1]

You cannot add custom entry there as a user unless you write a plugin that will do that.

WI-48160 / WI-45330 -- watch these tickets (star/vote/comment) to get notified on any progress.

The implementation of these tickets will bring a new entry in that list.


UPDATE 2019-10-08: PSR-12 Code Style preset has been added for 2019.3 version (currently in EAP stage).

Solution 2:[2]

You can now add it from the dropdown, must've changed some time in the past 2 years. enter image description here

Solution 3:[3]

PHPStrom Steps for setting coding style to PSR

Navgate to Preferences>Editor>Code Style>PHP

Click on "Set From" link and select PSR12.

Click ok to save the chages

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sarel
Solution 3 Amitesh Bharti