gossi/php-code-formatter
gossi/php-code-formatter is a PHP library for formatting PHP source code. It parses code into a token stream and applies configurable formatting rules, letting you enforce a consistent style programmatically or from the command line.
Consider adoption when:
FormatterInterface so the implementation is swappable, and your risk tolerance for a low-activity package is moderate.Look elsewhere when:
php-cs-fixer or PHP_CodeSniffer; a runtime library is the wrong shape.nikic/php-parser-based tooling.Adoption gate: run it against a corpus of your real generated PHP, confirm round-trip stability (format twice = idempotent), confirm it degrades gracefully on parse errors, and pin the version.
To executives: This is a small, MIT-licensed PHP library that lets us ship code-formatting capability inside the product in days rather than funding a multi-month formatter build. It directly improves the quality and readability of PHP we generate for customers — a visible trust signal — at near-zero licensing cost and no new infrastructure. The trade-off is maturity: the project has limited community adoption, so we mitigate by keeping it behind a thin internal interface and retaining a drop-in fallback. Recommendation: pilot it in a non-critical, user-visible-but-recoverable path, measure output quality and failure rate, and decide on broader rollout after one release cycle.
To engineering: Pure-PHP and embeddable — no external binaries, no container changes. We isolate it behind a FormatterInterface so we can swap to php-cs-fixer via subprocess or an AST-based approach without touching call sites. Please validate: supported PHP syntax versions versus our matrix, idempotency on our generated output, error handling on malformed input, and test coverage upstream. Treat it as a utility dependency, not a platform dependency — no feature should hard-fail because formatting failed.
How can I help you explore Laravel packages today?