Search by

adamczykpiotr / laravel-ultimate-formatter

adamczykpiotr

Ultimate code formatter for Laravel, taking care of everything

Package info

github.com/adamczykpiotr/laravel-ultimate-formatter

pkg:composer/adamczykpiotr/laravel-ultimate-formatter

Fund package maintenance!

AdamczykPiotr

Statistics

Installs: 882

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 7

v1.15.0 2026-11-15 19:33 UTC

README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Ultimate code formatter for Laravel, taking care of everything: one package that ships Rector and PHP CS Fixer with a shared, opinionated configuration, so every project formats its code the same way. A PHPStan ruleset reports what the formatters can't fix: banned calls and architecture rules.

Installation

composer require --dev adamczykpiotr/laravel-ultimate-formatter
vendor/bin/ultimate-formatter install

Supports Laravel 12–13 on PHP 8.3+.

install detects whether the project is an application or a package and publishes .php-cs-fixer.php, rector.php, phpstan.neon and .git-blame-ignore-revs, plus config/ultimate-formatter.php in an application. Existing files are skipped unless you pass --force, and --ci adds a GitHub Actions workflow. See Setup for the paths it picks and how to add the ruleset to an existing PHPStan config, and Adopting it in an existing project for the first run on a large codebase.

Usage

vendor/bin/ultimate-formatter format    # Rector, then PHP CS Fixer
vendor/bin/ultimate-formatter check     # dry run of both, then PHPStan; stops at the first failure (CI)

check runs PHPStan only when the project has a phpstan.neon, phpstan.neon.dist or phpstan.dist.neon. Before anything else it asks PHPStan whether that config loads the PHPStan ruleset, and fails with the includes to add when it doesn't, since the ruleset's rules would silently never run. Pass --without-phpstan-ruleset to run PHPStan without it.

format --models regenerates model docblocks with laravel-ide-helper first, which is installed with the package. In a Laravel app the same commands are available as php artisan formatter:install, formatter:format and formatter:check.

Flag Effect
-q Silences every step, so only the exit code reports the result
-v, -vv Prints each command before it runs and passes the same level to each step
-vvv As above, and passes --debug to Rector, which has no other verbosity flags

These flags replace any --quiet or -v in the configured arguments.

What it enforces

  • PHP CS Fixer: strict types, next-line braces, ordered imports and docblock tags, one sorted trait statement.
  • Rector: type declarations, Laravel sets, match, arrow functions, Carbon, and debug calls removed.
  • Custom rules: grouped numeric literals, === false/=== null instead of !, interpolation, early continue guards, and more.
  • PHPStan ruleset: banned calls, class naming and architecture rules, and migration conventions.

Documentation

Changelog

See CHANGELOG for what changed in each release.

Contributing

See CONTRIBUTING for running the tests and how releases work.

License

The MIT License (MIT). Please see License File for more information.