VS Code PHP Formatter Intelephense

30.9k Views Asked by At

I use Visual Studio Code as my editor and Intelephense as my PHP formatter. It works well for the most part, but Intelephense changes my format in several ways that makes it harder for me to read. For example, I like to format my code as follows:

    if( $var ) {
        // Do something.
    }
    elseif( $var ) {
        // Do something.
    }

But! When I save, Intelephense changes the above to:

    if ($var) {
        // Do something.
    } elseif ($var) {
        // Do something.
    }

To me, that's harder to read, especially when dealing with long expressions. How can I configure Intelephense to format my code as in the first example?

1

There are 1 best solutions below

4
On BEST ANSWER

Extensions > PHP Intelephense > Manage(click the gear) > Find Intelephense › Format: Braces and change or Find Intelephense › Format: Enable and remove tick.