Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Php Code Formatter Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Feature scoping — "format/beautify" in developer-facing products. Enables decisions on whether to ship a "Format code" action, auto-format-on-generate, or a copy-clean-snippet button inside tools like code generators, CMS/theme builders, migration utilities, low-code builders that emit PHP, or internal developer portals.
  • Build vs. buy for formatting capability. Building a PHP tokenizer + pretty-printer + PSR-12 rule set is weeks-to-months of specialized work; this package lets you buy (MIT, pure PHP) instead of build, and is a credible default for an in-process formatter.
  • Runtime vs. CI formatting. This supports the product decision to format code at request/generation time inside the application, which is distinct from pipeline linting. That distinction determines whether you adopt a library (runtime, embeddable) or a CLI tool (CI/pre-commit).
  • Code generation quality as a product surface. If your product emits PHP (scaffolding, exports, generated modules), formatted output is a trust and adoption signal — readable generated code measurably improves perceived quality and reduces support burden.
  • Roadmap sequencing for developer-experience features. A low-integration-cost formatting dependency makes "polish" DX items cheap to slot into a release; that changes prioritization math versus building formatting as a standalone epic.
  • Vendor/risk posture. Low star count and unknown upstream activity force an explicit decision: adopt behind an abstraction now, or defer until a maintained alternative is chosen.

When to Consider This Package

Consider adoption when:

  • You need to format PHP source as a string at runtime, inside your app, without spawning a subprocess or touching the filesystem.
  • You ship a feature that generates or templates PHP and want clean, consistent output without a CI dependency.
  • You want a small, MIT-licensed, pure-PHP dependency with no binary/toolchain requirement in your container images.
  • You are willing to wrap it behind an internal FormatterInterface so the implementation is swappable, and your risk tolerance for a low-activity package is moderate.
  • You have validated it against the PHP language versions you actually support (older formatters frequently lag on modern syntax such as enums, readonly properties, first-class callable syntax, and PHP 8.3+ constructs).

Look elsewhere when:

  • You only need CI/pre-commit enforcement — use php-cs-fixer or PHP_CodeSniffer; a runtime library is the wrong shape.
  • You need multi-language formatting — Prettier or language-specific toolchains are the correct answer.
  • You require long-term support, security patching, or vendor accountability — 31 stars and an indeterminate repository/homepage are material supply-chain concerns.
  • You need AST-aware rewriting, not just whitespace/style normalization — reach for nikic/php-parser-based tooling.
  • Your formatting requirements are exotic or style-configurable per tenant — verify rule coverage and configuration depth before committing, or you will end up forking.

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.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route