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 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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Enforce Consistent Code Style at Scale

    • Automate adherence to team/enterprise PHP coding standards (e.g., PSR-12, Symfony, Doctrine) without manual reviews.
    • Reduce cognitive load for developers by eliminating visual noise in diffs (e.g., inconsistent indentation, brace placement).
  • Accelerate Onboarding & Code Reviews

    • Standardize formatting to minimize "nitpicks" in PRs (e.g., trailing commas, line breaks).
    • Integrate with CI/CD pipelines to block non-compliant code (via check command + exit codes).
  • Build vs. Buy: Customization Over Out-of-the-Box

    • Buy: Use pre-built formats (e.g., SymfonyFormat, DoctrineFormat) for quick adoption.
    • Build: Extend with custom AFormat subclasses or override styles/rules for niche use cases (e.g., legacy codebases with unique patterns).
    • Example: Override DeclarationFormat to enforce next_line braces for all control structures in a legacy monolith.
  • Use Cases

    • Monorepos: Apply parallel processing (--workers=auto) to format 10K+ PHP files in minutes.
    • Legacy Refactoring: Use preview + diff to audit formatting changes before bulk apply.
    • Vendor Code: Normalize third-party PHP libraries (e.g., Laravel plugins) to match internal standards.
    • Education: Teach junior devs "correct" PHP syntax via enforced styles (e.g., keywordCase: 'lower').
  • Roadmap Alignment

    • Phase 1: Pilot with a single team (e.g., backend services) using DoctrineFormat.
    • Phase 2: Expand to shared libraries, with custom rules for cross-cutting concerns (e.g., NormalizeTrailingCommas globally).
    • Phase 3: Integrate with IDE plugins (e.g., PHPStorm) to auto-format on save, reducing manual apply runs.

When to Consider This Package

  • Adopt PHP-Styler When:

    • Your team struggles with inconsistent PHP formatting (e.g., mixed brace styles, random line breaks).
    • You need faster code reviews by reducing visual noise in diffs (e.g., 80% of PR comments are about indentation).
    • Your project uses PHP 8.1+ and can tolerate destructive formatting (no partial fixes).
    • You want opinionated defaults but need fine-grained control (e.g., Symfony’s style but with custom line length).
    • Your CI/CD pipeline already runs PHPStan/PHPUnit and can add a style check step.
  • Look Elsewhere If:

    • You need incremental/formatting (e.g., fix only trailing spaces). Use PHP CS Fixer with --dry-run.
    • Your codebase relies on horizontal alignment (e.g., aligned assignments). PHP-Styler deliberately breaks this.
    • You require string/heredoc splitting or comment formatting. Use Prettier PHP plugin or ECS.
    • Your team resists tooling and prefers manual standards (e.g., "just use VSCode’s built-in formatter").
    • You’re on PHP < 8.1. Consider PHP_CodeSniffer (PHPCBF) or PHP_Beautifier.
    • You need interactive formatting (e.g., format-on-save in IDE). PHP-Styler is CLI-only; pair with an IDE plugin.

How to Pitch It (Stakeholders)

For Executives (Business Impact)

*"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:

  • Ship faster: No more PR debates over indentation or brace placement.
  • Lower costs: Junior devs spend less time fixing formatting issues.
  • Improve quality: Consistent code is easier to debug and refactor.
  • Future-proof: Integrates with our CI/CD pipeline to block non-compliant code early.

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?"


For Engineering (Technical Value)

*"PHP-Styler is a high-performance, zero-dependency PHP formatter that:

  • Parses code into an AST, applies customizable rules, and rebuilds it—guaranteeing logic preservation.
  • Supports parallel processing (--workers=auto) to format thousands of files in minutes.
  • Integrates seamlessly with our stack:
    • CI/CD: Add ./vendor/bin/php-styler check to fail builds on formatting violations.
    • IDE: Use it alongside PHPStan for a one-pass linting/formatting workflow.
    • Legacy Code: Use 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:

  1. Week 1: Install and configure DoctrineFormat for a single service.
  2. Week 2: Add check to CI and gather feedback.
  3. Week 3: Customize rules (e.g., line length, brace styles) for team consensus.

Trade-offs:

  • Destructive: Runs a full rewrite (no partial fixes).
  • No horizontal alignment: Deliberate design choice for readability.
  • PHP 8.1+ only: Worth it for new projects; legacy systems may need PHP_CodeSniffer."*

Ask: "Should we start with DoctrineFormat or build a custom format from PlainFormat?"

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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui