DEV Community

Cover image for Run Laravel Pint With a Single Keyboard Shortcut in PhpStorm
Mahfuzur Rahman Saber
Mahfuzur Rahman Saber

Posted on

Run Laravel Pint With a Single Keyboard Shortcut in PhpStorm

PhpStorm’s External Tools have been around for ages—perfect for running command-line formatters like Laravel Pint only when you decide.

Why ditch the auto-save watcher?
In short, a keyboard shortcut keeps intentional control over when Pint rewrites your code.

Below is a zero-overhead setup that maps Pint to your favorite shortcut (⌥ ⌘ L in this example). Note that, of course you can use any shortcut you like but I replaced reformat code shortcut with Pint as it made sense to me.

Prereqs: a Laravel project with Pint installed
composer require --dev laravel/pint
You’ll need PhpStorm 2023.2+ for built-in Pint support. Read more

Configure Laravel Pint in PhpStorm

As this article is not about how to configure I suggest you to read this article from PhpStorm Docs

Create the external tool

Preferences → Tools → External Tools →

Navigate to external tools

Setting Value
Name Laravel Pint
Program $ProjectFileDir$/vendor/bin/pint
Arguments $FileRelativePath$
Working directory $ProjectFileDir$
Advanced options Uncheck Open console for tool output
(optional – I leave it off because the pop-up gets annoying)

Configure external tool settings for laravel pint

Bind it to a keyboard shortcut

Preferences → Keymap

  • Expand External Tools → Laravel Pint.
  • Right-click → Add Keyboard Shortcut.
  • Press ⌥ ⌘ L (or any combo).
  • If PhpStorm asks to remove the binding from Reformat Code, choose Remove—or pick a different shortcut if you’d rather keep the built-in formatter separate.

Happy (intentional) formatting! 🎉

Top comments (0)

OSZAR »