comlaude/php-formatter

Pre-configured php formatter

1.0.3 2023-11-14 16:17 UTC

This package is auto-updated.

Last update: 2024-04-14 17:10:49 UTC


README

Pre-configured php formatter using php-cs-fixer

Latest Stable Version License

Installation

Composer

Add the following to your require part within the composer.json:

"comlaude/php-formatter": "^1.0.0"
$ php composer update

or

$ php composer require comlaude/php-formatter

Integration

Lumen

Create a config folder in the root directory of your Lumen application and copy the content from vendor/comlaude/php-formatter/config/php-formatter.php to config/php-formatter.php.

Adjust the properties to your needs.

return [
    // A flag to enable/disable caching mode
    'cache' => false,
    // See https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/doc/rules/index.rst for available rules and rulesets
    'rules' => [
        '@PSR2' => true,
        '@DoctrineAnnotation' => true,
        'whitespace_after_comma_in_array' => true,
    ],
    // this is used to call function on configuring a finder as defined here https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/doc/config.rst
    'finder' => [
        'include'  => [],
        'exclude'  => ['bootstrap', 'vendor', 'storage'],
        'name'     => ['*.php'],
        'notname'  => ['*.blade.php'],
        'in'       => __DIR__ . '/../../../../',
    ];

Basic Usage

php vendor/bin/php-formatter fix

CI Automation usage

php vendor/bin/php-formatter fix -v --dry-run

License

This package is open-sourced software licensed under the MIT license