Skip to content

Instantly share code, notes, and snippets.

@adrianovcar
Last active March 15, 2024 10:53
Show Gist options
  • Save adrianovcar/2e91d9ced04d1ebadd0ab130af8ff773 to your computer and use it in GitHub Desktop.
Save adrianovcar/2e91d9ced04d1ebadd0ab130af8ff773 to your computer and use it in GitHub Desktop.
Laravel Pint - PHPStorm Auto Formatter

I'm assuming you already have installed Laravel Pint on your project, if not, follow the official installation guide

To set up the integration with Laravel Pint, open your PHPStorm and proceed to SettingsPHPQuality Tools and unfold the Laravel Pint segment.

If you are working on a pre-existing project, I recommend checking the option Reformat only uncommitted files.

Additionally, you have the option to designate Laravel Pint as your preferred external formatter. This facilitates the correction of all problems identified by Laravel Pint simultaneously using the Reformat Code ⌘⌥ L command.

To activate Laravel Pint for inspection within PhpStorm, navigate to SettingsEditorInspections and mark the checkbox for Laravel Pint Validation found under PHPQuality Tools.

Optional

You can define custom rules for your Pint validation. Just create a pint.json file on your project root, here is an example:

{
    "preset": "laravel",
    "rules": {
        "simplified_null_return": true,
        "braces": false,
        "new_with_braces": {
            "anonymous_class": false,
            "named_class": false
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment