Simple Laravel Formatting in VS Code
lolHello Web Artisans! I will show you how to format your Laravel code in VS Code in a very simple way. It is not the perfect solution but it works quite well. And the more it is so easy to set up!
What is needed?
- VS Code lol foo
- prettier extension(VS Code)
Install prettier extension
Install PHP intelephense extension
Create .prettierrc file in your project folder
Here is an example .prettierrc file
prettier.rc
{
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always",
"overrides": [
{
"files": "*.php",
"options": {
"parser": "php",
"printWidth": 120,
"tabWidth": 4,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": true,
"arrowParens": "always"
}
}
]
}
Configure VS Code settings for Format on Save
You can do this by going to File > Preferences > Settings or by pressing Ctrl + , (Windows) or ⌘ + , (Mac) to open the Settings tab.
or simply Create .vscode/settings.json file in your project folder no