Skip to content

Instantly share code, notes, and snippets.

  • Save lunitrixx/46d1741a7ca348f694f1f52f7e64d190 to your computer and use it in GitHub Desktop.
Save lunitrixx/46d1741a7ca348f694f1f52f7e64d190 to your computer and use it in GitHub Desktop.
Setup PhpStorm to use Prettier and Laravel Pint (Antlers, Blade, PHP, Tailwind, Statamic)

Install dependencies

Run npm install -D prettier prettier-plugin-antler prettier-plugin-blade-stillat prettier-plugin-tailwindcss in your terminal

Configure prettier

Create a .prettierrc file with the following content

{
    "singleQuote": true,
    "trailingComma": "all",
    "printWidth": 140,
    "tabWidth": 2,
    "endOfLine": "lf",
    "plugins": [
        "./node_modules/prettier-plugin-antlers/",
        "./node_modules/prettier-plugin-blade-stillat/"
    ],
    "overrides": [
        {
            "files": "*.antlers.html",
            "options": {
                "parser": "antlers"
            }
        },
        {
            "files": "*.blade.php",
            "options": {
                "parser": "blade"
            }
        },
        {
            "files": [
                "**/*.css",
                "**/*.html",
                "**/*.php"
            ],
            "options": {
                "singleQuote": false
            }
        }
    ]
}

Register prettier as formatter

Under Settings > Languages & Frameworks > JavaScript > Prettier register the following pattern for Run for Files. `{**/,}.{js,ts,jsx,tsx,antlers.html,blade.php}z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment