Laravel中的統一代碼風格

在開發中,保證我們的代碼風格一致,可以避免引起不必要的歧義。

在開發中,我們可以使用 EditorConfig 插件(筆者使用VSCode 開發工具)來統一我們的代碼風格。

在實際Laravel 應用中使用的規範如下,值得參考:

在 Laravel 應用的根目錄下修改 .editorconfig 文件,並寫入如下的配置信息:

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{yml,yaml}]
indent_size = 2

[*.{js,html,blade.php,css,scss}]
indent_style = space
indent_size = 2
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章