A slim, opinionated wrapper around PHPCSFixer.
This comes preloaded with sane style choices for most PHP applications. You should be able to safely run it on most code out of the box.
- Require the package
composer require jspaetzel/phpstyle --dev
🗒 Note: This package is a composer plugin, when installed it will create an initial
phpstyle.neon
file and a managed.php-cs-fixer.dist.php
file in the root of your project. You may be prompted before this action takes place.
-
Review the
phpstyle.neon
configuration file. Feel free to make changes to this file at any time. -
Run php-cs-fixer to fix your code
./vendor/bin/php-cs-fixer fix
🗒 Note: php-cs-fixer is integrated with PHPStorm and other editors and so PHPStyle should work with them as well.
That's it, your code is styled!
The configuration for PHPStyle takes inspiration from PHPStan and is a very simple neon configuration file. Just adjust your paths and php versions if needed, and you'll be good to go.
parameters:
php: 7.1
risky: false
paths:
- src
- tests
excludePaths:
- src/path/you/want/to/skip
- src/or/a/file-to-skip.php
Want to enable more rules? change
risky: true
and then see what happens. But watch out, these are risky! ⚠