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

PHP-Styler is a PHP 8.1+ code formatter that fully rewrites source formatting to produce consistent, diff-friendly output. It tokenizes code with PhpToken, applies configurable Styles, Rules, and Parses, then reassembles and splits lines to match your preferred layout and maximum line length.

  • Logic-preserving reformatting that keeps behavior intact
  • Consistent horizontal/vertical spacing (indentation, blank lines)
  • Automatic line-length control with prioritized line splitting
  • Highly customizable formats via token styles and structural rules
  • Comment preservation (EOL comments stay put; block comments retained)
Frequently asked questions about Php Styler
Can PHP-Styler safely format Laravel’s core files (e.g., src/, framework/src/) without breaking functionality?
Yes, PHP-Styler is designed to preserve code logic while reformatting, but test thoroughly in a staging environment first. Avoid running it on vendor/ or Blade templates, as aggressive reformatting may disrupt syntax like @php directives or custom alignment in legacy code.
How does PHP-Styler handle Laravel’s Blade templates or SQL queries in Eloquent models?
PHP-Styler does not split or reformat long strings/heredocs, so Blade templates or SQL queries will remain unchanged. However, avoid applying it to Blade files entirely, as it may misinterpret @php blocks or custom formatting.
Is PHP-Styler compatible with Laravel’s existing PHP-CS-Fixer configuration?
No, PHP-Styler is a replacement, not a complement. You’ll need to migrate or deprecate your .php-cs-fixer.dist.php config. Start with the default PHP-Styler config and adjust for Laravel’s PSR-12/Symfony standards.
Will PHP-Styler work with older Laravel versions (pre-PSR-12) or custom-coded packages?
It may require extensive configuration tweaking. PHP-Styler’s aggressive reformatting could conflict with legacy formatting (e.g., use blocks, docblocks with custom alignment). Test incrementally and document exceptions in your team’s style guide.
How can I integrate PHP-Styler into Laravel’s CI/CD pipeline (e.g., GitHub Actions)?
Use the `check` command to enforce formatting consistency in CI. Example: `php artisan test --workers=4` or add a step like `vendor/bin/php-styler check src/ tests/`. For large repos, tune `--workers` to balance speed and memory usage.
Does PHP-Styler support incremental formatting (like PHP-CS-Fixer’s `--dry-run`)?
No, PHP-Styler performs a full rewrite of targeted files. There’s no ‘fix only what’s needed’ mode, so use it cautiously on large codebases. Backup files or use Git to revert if needed.
How does PHP-Styler handle edge cases like magic methods (__get(), __set()) or dynamic code (eval())?
Logic is preserved, but edge cases like magic methods or dynamic code (e.g., `eval()`, `token_get_all()`) might fail silently or produce malformed output. Test thoroughly, especially in Laravel’s Facade helpers or Artisan commands.
Can PHP-Styler conflict with IDE plugins (e.g., PHP-CS-Fixer for VSCode) that auto-format on save?
Yes, conflicts are likely. Standardize your team on one tool—either PHP-Styler or an IDE plugin—to avoid inconsistent formatting. Disable auto-format in IDEs if using PHP-Styler globally.
What’s the performance impact of running PHP-Styler on a large Laravel codebase (e.g., 10K+ files)?
Parallel processing (`--workers=N`) mitigates bottlenecks, but memory usage can strain CI environments or low-memory servers. Start with `--workers=4` and monitor resource usage. Cache parsed files for repeated runs.
Are there alternatives to PHP-Styler for Laravel that offer incremental formatting?
Yes, consider PHP-CS-Fixer (supports incremental fixes) or Prettier (via Babel/ESLint plugins for PHP). PHP-CS-Fixer is more widely adopted in Laravel ecosystems and integrates with tools like Laravel Pint.
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.
croct/coding-standard
croct/plug-php
nqxcode/phpmorphy
boundwize/pyrameter
develia/commons
dmstr/symfony-system-resources-bundle
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
renatomarinho/laravel-page-speed
develia/geo-bundle
austinheap/laravel-database-encryption
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
imbo/imbo-coding-standard
visualbuilder/filament-lottie
servicioslineaonce/starter-kit
atomcoder/laravel-reorderable
irajul/filament-shadcn-theme
agtp/agtp-php