Search code examples
visual-studio-codephpstorm

PhpStorm Formatter failed to format the document


Similar questions have been asked, but what makes mine different is that I seem to have the configuration correct. Here is my configuration (my name has been redacted, for privacy reasons).

enter image description here

What I know is that my PhpStorm IDE has not been activated yet; is that required or is my configuration incorrect, despite the folder and file being at these places?


Solution

  • So you're trying to use PhpStorm from within VSCode to format your files. Which means: calling PhpStorm as a command-line app.

    I'm pretty sure that PhpStorm has to have a valid active licence or be in the evaluation period (so it has be "activated" in some way). I remember seeing tickets with similar issue when using PhpStorm for code inspections in Continuous Integration tools.

    In any case:

    1. Check what command VSCode is trying to execute here, then open your OS console and try to run it there -- will you see any errors/warnings in the output?

    2. If you do not see any such messages there then check the idea.log file -- the IDE will write everything there for sure.

      On Windows it would normally be in the C:\Users\USERNAME\AppData\Local\JetBrains\PhpStorm2022.2\log folder (for the current 2022.2 version). Other OS / cusom location -- check https://www.jetbrains.com/help/phpstorm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#logs-directory


    ...or is my configuration incorrect, despite the folder and file being at these places?

    As per docs the Code Style settings file can be located anywhere: it can be in the default place as well as any other as it can be passed as an argument in the command line (-s parameter). So keeping the file with Code Style settings in the VSCode extension folder is OK as long as that parameter is used.