pmjones/php-styler
PHP-Styler is a PHP 8.1+ code formatter that fully reformats your code for consistent spacing, indentation, and line lengths. It preserves logic and comments, is diff-friendly by default, and is customizable via styles, rules, and parses.
Enforce Consistent Code Style at Scale
Accelerate Onboarding & Code Reviews
check command + exit codes).Build vs. Buy: Customization Over Out-of-the-Box
SymfonyFormat, DoctrineFormat) for quick adoption.AFormat subclasses or override styles/rules for niche use cases (e.g., legacy codebases with unique patterns).DeclarationFormat to enforce next_line braces for all control structures in a legacy monolith.Use Cases
--workers=auto) to format 10K+ PHP files in minutes.preview + diff to audit formatting changes before bulk apply.keywordCase: 'lower').Roadmap Alignment
DoctrineFormat.NormalizeTrailingCommas globally).apply runs.Adopt PHP-Styler When:
Look Elsewhere If:
--dry-run.*"PHP-Styler lets us automate 90% of code formatting, cutting review cycles by 30% and reducing onboarding friction. By standardizing our PHP style, we’ll:
It’s like Prettier for JavaScript, but for PHP—just run php-styler apply, commit the changes, and move on. We can start with Symfony’s style guide and tweak it for our needs."*
Ask: "Should we pilot this with the backend team first, or roll it out to all PHP services?"
*"PHP-Styler is a high-performance, zero-dependency PHP formatter that:
--workers=auto) to format thousands of files in minutes../vendor/bin/php-styler check to fail builds on formatting violations.preview + diff to audit changes before bulk reformatting.Key Advantages Over Alternatives:
| Tool | AST-Based | Parallel | Custom Rules | Opinionated Formats |
|---|---|---|---|---|
| PHP-Styler | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
| PHP CS Fixer | ❌ No | ❌ No | ✅ Yes | ❌ Limited |
| Prettier PHP | ✅ Yes | ❌ No | ❌ No | ❌ No |
Proposal:
DoctrineFormat for a single service.check to CI and gather feedback.Trade-offs:
Ask: "Should we start with DoctrineFormat or build a custom format from PlainFormat?"
How can I help you explore Laravel packages today?