HookyQR / VSCodeBeautify

Enable js-beautify (https://github.com/beautify-web/js-beautify) in VS Code
MIT License
607 stars 177 forks source link

How to add php to beautify? #313

Open Zolak94 opened 5 years ago

Zolak94 commented 5 years ago

I added this code to my settings.json

"beautify.language": {
        "js": {
          "type": ["javascript", "json"],
          "filename": [".jshintrc", ".jsbeautifyrc"]
          // "ext": ["js", "json"]
          // ^^ to set extensions to be beautified using the javascript beautifier
        },
        "php": {
            "type": ["php"],
            "filename": [".php"]
            // "ext": ["js", "json"]
            // ^^ to set extensions to be beautified using the javascript beautifier
          },
        "css": ["css", "scss"],
        "html": ["htm", "html", "blade.php", "php"]
        // ^^ providing just an array sets the VS Code file type
      }

Action performed

I want to format my php code in my Laravel app in Controller which has extension Controller.php when i press ctrl + shift + p and select Beautify selection I can only choose between: HTML, CSS and JavaScript.

Expected results

Expected results is to have PHP in Beautify selection.

Actual results

when i press ctrl + shift + p and select Beautify selection I can only choose between: HTML, CSS and JavaScript. How can I add PHP?

kanlukasz commented 5 years ago

Beautify doesn't support PHP.

If you want beautify PHP files, you have to use different addon, example:

Additionally, read this Stackoverflow post , maybe it can help you because it's about blade files:

Apart from your question, read about PSR-2: