DEV Community

Süleyman Özgür Özarpacı
Süleyman Özgür Özarpacı

Posted on

PHPStorm Auto Format with Laravel Pint

Code fixers such as PHPCSFixer play a vital role in maintaining high code quality and consistency. These tools detect and rectify coding style issues, ensuring that the codebase follows predefined standards. By enforcing uniform formatting, code fixers enhance readability, promote better collaboration among developers, and significantly reduce the time spent on manual code reviews and corrections.

In the context of Laravel, Pint can be utilized for this purpose. This article focuses on running Pint. To configure the automatic execution of Pint when saving a file in Laravel, follow these steps:

  1. Open the settings page by pressing CTRL + ALT + S.
  2. Type "File Watcher" in the search bar.
  3. Click the + (plus) icon.
  4. Select "Custom" from the options.

Fill out the form as follows:

  • Name: Laravel Pint (you can change this)
  • File Type: PHP
  • Scope: Current File (to only format the current file)
  • Program: $ProjectFileDir$\vendor\bin\pint
  • Arguments: $FilePath$

Next, open the "Advanced Options" section below and check the box for "Trigger the watcher on external changes". Save the file watcher and enable the watcher. Now you can edit a PHP file to see if it works.

Top comments (1)

Collapse
 
vedatkurtay profile image
Vedat Kurtay

That was really help to me, thanks a lot!