prettier / plugin-php

Prettier PHP Plugin

Home Page:https://loilo.github.io/prettier-php-playground/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recommended configuration for using plugin-blade together with plugin-php?

vinkla opened this issue · comments

What is the best way to use both @shufo/prettier-plugin-blade and @prettier/plugin-php together for proper formatting of PHP and Blade files? Currently, I can only use one of them, since they override each other, and it seems @shufo/prettier-plugin-blade is being used instead of @prettier/plugin-php for PHP files with the following config:

// prettier.config.js
module.exports = {
  singleQuote: true,
  plugins: [
    require('@prettier/plugin-php'),
    require('@shufo/prettier-plugin-blade')
  ],
  overrides: [
    {
      files: ['*.php'],
      options: {
        parser: 'php',
      },
    },
    {
      files: ['*.blade.php'],
      options: {
        tabWidth: 4,
        parser: 'blade',
      },
    },
  ],
};
// package.json
{
  "private": true,
  "type": "module",
  "dependencies": {
    "@prettier/plugin-php": "^0.19.4",
    "@shufo/prettier-plugin-blade": "^1.8.12",
    "prettier": "^2.8.8"
  }
}
// .vscode/settings.json
{
  "[blade][php]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "prettier.documentSelectors": ["**/*.php"]
}

I haven’t used the blade plugin yet - it might be a good idea to also open an issue about this in the blade plugins repo?

@czosel you are right, I forgot to link it: shufo/prettier-plugin-blade#198

The issue was resolved by replacing @shufo/prettier-plugin-blade with prettier-plugin-blade.