Skip to content

Local Setup: PHPStorm Prettier Plugin

bree edited this page Nov 9, 2020 · 3 revisions

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

Setup

  1. Add the Prettier Plugin to PHPStorm

    1. Open PHPStorm's preferences (Cmd-, on macOS)
    2. Click Plugins
    3. Select Marketplace and type "Prettier" into the search
    4. Click Install

    note: PHPStorm may need to be restarted for the plugin to be active

  2. If a restart was required reopen PHPStorm's preferences

  3. Click Language & Frameworks

  4. Click Javascript

  5. Click Prettier

  6. Make sure the Node interpreter: field is properly set

  7. Make sure the Prettier package: field has the path to the prettier packager ie. .../git-sandbox/node_modules/prettier

  8. In the Run for files: field add the following between the curly braces css,scss,sass,json,php

  9. Check the box next to On code reformat and On save

  10. Click Apply at the bottom of the preferences window

Use

  • On macOS: reformat with prettier by pressing Opt-Shift-Cmd-P
  • On Windows/Linux: reformat with prettier by pressing Alt-Shift-Ctrl-P

Clone this wiki locally