eduarguz/shift-php-cs

PHP CS Fixer - Laravel Coding Style Ruleset

1.0.1 2021-01-02 01:45 UTC

This package is auto-updated.

Last update: 2021-04-13 18:37:38 UTC


README

This package allows you to use the set of rules for PHP CS Fixer created and recommended by Laravel Shift.

You can find the original and official source of the ruleset in this gist.

Installation

You can install the ruleset via composer using the following command:

composer require --dev eduarguz/shift-php-cs

This package will also require the friendsofphp/php-cs-fixer package.

Usage

This package only gives you easy access to the recommended ruleset. The common and usual PHP-CS-Fixer setup is still required:

In case you don't have one, create your .php_cs.dist file.

touch .php_cs.dist

Put your Finder config inside. This will tell PHP-CS-Fixer where to run.

Usually, for a Laravel Project this is the config:

<?php

use PhpCsFixer\Finder;

$project_path = getcwd();
$finder = Finder::create()
    ->in([
        $project_path . '/app',
        $project_path . '/config',
        $project_path . '/database',
        $project_path . '/resources',
        $project_path . '/routes',
        $project_path . '/tests',
    ])
    ->name('*.php')
    ->notName('*.blade.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

return \ShiftCS\styles($finder);

Run your fixer.

./vendor/bin/php-cs-fixer fix

Run on CI

./vendor/bin/php-cs-fixer fix --dry-run

Resources