pmjones/php-styler
PHP-Styler is a PHP code formatter that tokenizes source files and rebuilds them with consistent spacing, indentation, and automatic line splitting. Configurable Styles, Rules, and Parses customize the diff-friendly output, while logic and comments are preserved. No dependencies beyond PHP 8.1.
Format object (PHP code returning a Config) is versionable and diffable, which supports a "one format definition, many repos" rollout — attractive for platform teams who want a shared php-styler.php in a base template.check command returns exit code 1 on drift, so it fits a build-pipeline decision: format-check on PR, apply in a pre-commit hook or a scheduled bot commit..git-blame-ignore-revs workflow explicitly supports a real product decision: "we accept one large, disposable reformat commit." That's a planning item (freeze window, comms, git blame config per developer) more than an engineering item.Percs30Format, SymfonyFormat, DoctrineFormat) approximate popular standards. If a decision hinges on auditable PSR-12/PER compliance, this package is not the answer regardless of how good the output looks.Consider it when:
= and -> chains get flattened).proc_open, portable to Windows), and you value a config that lives in php-styler.php as first-class PHP rather than YAML/XML.Look elsewhere when:
git blame for months.Executive framing: A free, MIT-licensed, self-contained PHP formatter that removes formatting from code review entirely. No new runtime dependency, no licensing cost, no PHP extensions, runs in parallel. The pitch is cycle time and onboarding, not features — reviewers stop commenting on whitespace, and new engineers get a machine-enforced house style on their first commit.
Engineering framing: An opinionated reformatter in the Black/Prettier mold, built on PHP's native PhpToken lexer with a clean six-stage pipeline (parse → token rules → assemble → split → line rules → render). Customization is declarative — Format objects composing styles, rules, and parseAs — so house style is a reviewable PHP file rather than a pile of overrides. Ships PlainFormat and DeclarationFormat plus vendor approximations, supports automatic line-length splitting with prioritized split points and an @php-styler-expansive escape hatch, and offers preview/diff/check so the change is auditable before it lands.
The honest caveat to lead with, not bury: it completely discards existing formatting. Landing it means one big reformat commit, a .git-blame-ignore-revs entry, a coordinated freeze, and a pinned version while the project is pre-1.0. Recommend a time-boxed trial on a single non-critical package first — run diff on one directory, measure how much churn is stylistic vs. semantic, and only then decide whether the determinism payoff justifies the transition cost. If the trial shows heavy diff noise on code we care about, the correct product decision is to stay on Pint/PHP CS Fixer and revisit at 1.0.
How can I help you explore Laravel packages today?