Repository navigation
Local Setup: PHPStorm Prettier Plugin
We're using Prettier to format our PHP, JS, CSS, HTML, and MD files
This will happen upon creating a commit with a file that matches one of the above types
You may also setup PHPStorm to format the files as soon as the file is saved
-
Add the Prettier Plugin to PHPStorm
- Open PHPStorm's preferences (Cmd-, on macOS)
- Click Plugins
- Select Marketplace and type "Prettier" into the search
- Click Install
note: PHPStorm may need to be restarted for the plugin to be active
-
If a restart was required reopen PHPStorm's preferences
-
Click Language & Frameworks
-
Click Javascript
-
Click Prettier
-
Make sure the Node interpreter: field is properly set
-
Make sure the Prettier package: field has the path to the prettier packager ie.
.../git-sandbox/node_modules/prettier -
In the Run for files: field add the following between the curly braces
css,scss,sass,json,php -
Check the box next to On code reformat and On save
-
Click Apply at the bottom of the preferences window
- On macOS: reformat with prettier by pressing Opt-Shift-Cmd-P
- On Windows/Linux: reformat with prettier by pressing Alt-Shift-Ctrl-P