Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

jspaetzel/phpstyle

Repository files navigation

PHPStyle ✨

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.

https://php.style/

🏗 Setup

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

  1. Review the phpstyle.neon configuration file. Feel free to make changes to this file at any time.

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

⚙ Configuration

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! ⚠