When editing Magento2 .phtml files, it would be nice to use the code formating function of PhpStorm, but without changing the original layout (just format added stuff).

So did anybody already set up PHPStorm's format settings for Magento2 and would like to share them?

2 Answers 2


Magento 2 team use PSR1/PSR2 code styles (in PHPStorm: preferences > Code Style > PHP > set from > PSR1/PSR2) and verify it with static test Magento\Test\Php\LiveCodeTest::testCodeStylePsr2


Basically it seems to be ident = 4 spaces. But they sometimes align the equals signs:

<?php $_option = $block->getOption(); ?>
<?php $_selections  = $_option->getSelections(); ?>
<?php $_default     = $_option->getDefaultSelection(); ?>
<?php list($_defaultQty, $_canChangeQty) = $block->getDefaultValues(); ?>

This looks wrong to me, as it is not consequent and should be fixed.

  • You're correct, space aligning is acceptable, but should either be applied consistently or not at all.
    – Ryan Hoerr
    Commented Oct 12, 2015 at 12:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.