comlaude/php-formatter

Pre-configured php formatter

1.0.4 2024-06-17 10:49 UTC

This package is auto-updated.

Last update: 2024-11-17 11:36:14 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,
    ],
    // You can initialises your own ParallelConfig class here with your desired parameters
    // default is set to detect the environment and use the appropriate resources
    'parallel' => PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect(),
    // 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