pretty-php is an opinionated code formatter for PHP. It is designed to make PHP source code consistent without requiring developers to spend time choosing or maintaining an extensive collection of style rules.
The formatter takes a deterministic approach: the same input and settings produce the same formatting, helping projects avoid stylistic differences between contributors and making code review easier to follow. Its philosophy is influenced by Black, the Python formatter, with an emphasis on sensible defaults, predictable output, and producing small, readable diffs. It can be used as a standalone command-line tool or incorporated into a broader development workflow alongside linters and other quality checks.
This is free and open source software.
Key Features
- Formats complete PHP files in place.
- Offers a diff mode for reviewing proposed formatting changes without replacing files.
- Checks formatted output against the original code for equivalence.
- Supports PSR-12 and the PHP Extended Coding Style specification.
- Includes presets for Symfony, Drupal, Laravel and WordPress coding styles.
- Can group and sort import statements.
- Provides controls for operator placement and treatment of existing newlines.
- Can normalize strings and numeric literals.
- Trims and aligns comments and removes empty DocBlocks.
- Supports optional configuration through a JSON file while remaining usable without configuration.
- Can be integrated with editors and continuous integration workflows.
- Provides options for selectively disabling formatting rules.
Website: github.com/lkrms/pretty-php
Support:
Developer: Luke Arms
License: MIT License
pretty-php is written in PHP. Learn PHP with our recommended free books and free tutorials.
Related Software
| PHP Code Formatters | |
|---|---|
| PHP Coding Standards Fixer | Fix coding style issues automatically |
| Mago | Fast linting, style checking and static analysis |
| PHP_CodeSniffer | Detect violations of defined coding standards |
| pretty-php | Apply consistent, opinionated source styling |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.