Weave Code
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 Styler Laravel Package

pmjones/php-styler

PHP-Styler is a PHP 8.1 code formatter that fully rewrites formatting for consistent spacing, indentation, and line splitting. It preserves code logic and comments, aims for diff-friendly output, and supports customizable styles/rules for structural transformations.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enforce Consistent Code Style at Scale Adopting php-styler enables teams to standardize PHP code formatting across repositories, reducing cognitive load for developers and minimizing noise in code reviews. This aligns with initiatives to improve developer productivity and maintainability.

  • Automate Code Quality Gates Integrate php-styler into CI/CD pipelines to enforce formatting rules as a pre-commit or pre-merge check, reducing manual effort and ensuring compliance with team standards. This supports a "shift-left" quality strategy.

  • Migrate to Modern PHP Standards For projects adopting PHP 8.1+, php-styler provides a lightweight alternative to complex tools like PHP-CS-Fixer, with built-in support for modern syntax (e.g., arrow functions, named arguments, match expressions). This enables teams to modernize their codebase without heavy tooling overhead.

  • Customizable Formatting for Niche Use Cases Teams with specific formatting needs (e.g., Doctrine, Symfony, or PER coding standards) can leverage pre-built vendor formats or extend the tool via Styles, Rules, and Parses. This avoids reinventing the wheel for edge cases like:

    • Opinionated brace placement (e.g., "next line" for classes, "same line" for control structures).
    • Normalizing trailing commas or import ordering.
    • Converting else if to elseif or array() to [].
  • Build vs. Buy Decision Buy: If the team lacks the bandwidth to maintain a custom formatter or requires rapid adoption of a standardized style. php-styler’s MIT license and lack of dependencies (beyond PHP 8.1) reduce adoption friction. Build: Only if the team needs highly specialized formatting logic not covered by existing Styles/Rules (e.g., domain-specific alignment or legacy code transformations). In such cases, forking and extending php-styler may be preferable to building from scratch.

  • Use Cases

    • Onboarding: Standardize new contributor code to match the team’s style.
    • Refactoring: Clean up legacy codebases with inconsistent formatting.
    • Open Source: Enforce a single style across multiple repositories (e.g., a monorepo or ecosystem).
    • Legacy Modernization: Gradually apply formatting to old codebases without breaking logic.

When to Consider This Package

  • Adopt php-styler when:

    • Your team prioritizes consistency over customization and wants a tool that enforces a single, opinionated style without requiring deep configuration.
    • You need a lightweight alternative to PHP-CS-Fixer (e.g., for projects where PHP-CS-Fixer’s complexity is prohibitive).
    • Your codebase uses PHP 8.1+ and benefits from modern syntax support (e.g., arrow functions, match expressions).
    • You want built-in parallel processing to format large codebases efficiently (e.g., --workers=auto).
    • Your team values diff-friendly formatting (e.g., minimal noise in Git diffs) and logic preservation (no semantic changes).
    • You need pre-built formats for popular standards (e.g., Symfony, Doctrine) or want to extend them via Styles/Rules.
  • Look elsewhere when:

    • You require fine-grained, rule-based customization (e.g., conditional formatting based on file paths or AST analysis). Tools like PHP-CS-Fixer or ECS offer more granular control.
    • Your team relies on horizontal alignment (e.g., aligning assignment operators or method chaining). php-styler intentionally avoids this to reduce maintenance burden.
    • You need to preserve complex comment formatting (e.g., multi-line docblocks with embedded code). php-styler simplifies comments aggressively.
    • Your codebase includes legacy PHP (<8.1) or relies on non-standard syntax (e.g., custom PHPTAL templates). Compatibility may be limited.
    • You want interactive formatting (e.g., real-time feedback in an IDE). php-styler is CLI-focused, though it could be integrated with tools like PHPStorm or VSCode via custom tasks.

How to Pitch It (Stakeholders)

For Executives:

*"php-styler is a lightweight, high-impact tool to standardize our PHP codebase, reducing technical debt and improving developer velocity. By automating formatting—similar to how Black does for Python—we can:

  • Cut code review time by eliminating style nitpicks (e.g., brace placement, line length).
  • Onboard engineers faster with consistent, tool-enforced standards.
  • Integrate seamlessly into CI/CD as a pre-commit check, catching issues early.
  • Avoid tooling sprawl by replacing multiple ad-hoc formatters with a single, maintainable solution.

It’s battle-tested (used in production since 2026), has zero dependencies beyond PHP 8.1, and supports parallel processing to handle large codebases efficiently. The upfront cost is minimal—just a composer require—and the ROI comes from reduced cognitive load and fewer merge conflicts."*

For Engineering Teams:

*"php-styler is a modern PHP formatter that:

  • Preserves logic while enforcing a clean, consistent style (e.g., 84-character lines, 4-space indents).
  • Supports our stack: Works out-of-the-box with PHP 8.1+ and integrates with Symfony/Doctrine/PER standards.
  • Saves time: Parallel processing (--workers=auto) formats entire repos in minutes, not hours.
  • Reduces friction: The check command flags unstyled files, and diff shows exactly what’s changing. No more ‘it looks fine to me’ debates.
  • Extensible: Need to tweak brace placement or normalize imports? Override the default Styles or Rules in your config.

Key differentiators vs. PHP-CS-Fixer:

  • Simpler to configure (opinionated defaults vs. hundreds of rules).
  • Faster execution (no complex rule engine).
  • Better for diffs (minimal noise).

Next steps:

  1. Run composer require --dev pmjones/php-styler in a sandbox repo.
  2. Try ./vendor/bin/php-styler preview src/ to see how it handles our code.
  3. Pilot in CI with php-styler check as a pre-merge gate.

Let’s start with the DeclarationFormat (opinionated for classes/functions) and adjust as needed."*

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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor