Skip to content

pint 代码风格

Laravel Pint 支持开箱即用的代码风格检查和修复。

通过在项目根目录下添加 pint.json 来制定自定义的代码风格,更多自定义风格配置可以查看这里

文件内容如下:

yml
{
    "preset": "laravel",
    "rules": {
        "ordered_imports": {
            "sort_algorithm": "length",
            "imports_order": [
                "const",
                "class",
                "function"
            ]
        }
    }
}

ordered_imports 格式化 PHP 中类的 use 语句,排序的规则使用字符长度,导入顺序按照 constclassfunction