PHP Storm and Laravel Pint
If you want Laravel Pint to reformat your PHP code automatically when you save your file in PhpStorm, you can set it up as a file watcher and run it as an “action on save”. To do this, you need to disable PhpStorm’s built-in code formatting for PHP.
Follow these steps to set up Laravel Pint as a file watcher in PhpStorm:
- Create a new File Watcher for Laravel Pint.
- Use the following settings for the file watcher:
- Output paths to refresh:
- Working directory:
To ensure it’s functioning correctly during setup, you can enable the “Always” option. Following that, my preference is for “On error.”
Got an error in macOS: “env: php: No such file or directory”
If you’re using newer macOS systems, you may have encountered an issue with PHPStorm where it cannot find the PHP binary to execute. This is because PHP is no longer included on newer macOS versions. However, if you have Brew installed, you can easily resolve this issue by adding the Brew version of PHP to the path
/usr/local/bin. By doing so, you’ll be able to use PHPStorm without any problem and continue working on your PHP projects.
PHPStorm is formatting my code before Laravel Pint can run.
Disable PhpStorm’s built-in code formatting for PHP.