PrettyPHP is an opinionated code formatter that is a fast, deterministic code formatter for PHP, written in PHP. It has sensible defaults and runs without configuration.
$ pretty-php apppretty-php v0.4.94 (2bf41b46) PHP 8.4.2- Replacing app/Http/Controllers/Controller.php✔ Replaced 1 of 3 files successfully in 0.037s (10.092MiB memory used)
This CLI also has a VS Code extension to format your files on save.
I am not encouraging you to ditch Laravel Pint to handle formatting in your Laravel projects. However, this project, being a PHP formatter, indicates a healthy PHP ecosystem that is growing with new tools. I like that pretty-php tool is opinionated, and using it to format your projects will ensure consistent formatting across all files you edit. It also comes with default code styles for Symfony, Drupal, Laravel, and WordPress.
Main Features
- Formats code written for PHP 8.4 and below (when running on a compatible version of PHP), including property hooks
- Code is formatted for readability, consistency, and small diffs
- Previous formatting is ignored, and nothing other than whitespace is changed
- Entire files are formatted in place
- Formatting options are deliberately limited (pretty-php is opinionated so you don't have to be)
- Configuration via a simple JSON file is supported but not required
- Formatted and original code are compared for equivalence
- Compliant with PSR-12 and PER (see PSR-12 compliance for details)
- Supports Symfony, Drupal, Laravel and WordPress code styles via presets
💻 You can get started with this package on GitHub: lkrms/pretty-php
📕 Read more about the .prettyphp configuration file