Skip to content

Laravel Shift recommended style config

Notifications You must be signed in to change notification settings

aloware/shift-php-cs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PHP CS Fixer - Laravel Coding Style Ruleset

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

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 aloware/shift-php-cs:dev-master

This package will also require the ^3.0 version of 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-fixer.php file.

touch .php-cs-fixer.php

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

Upgrade from 1.x to 3.x version of this package (to PHP-CS-Fixer 3.x)

composer require --dev aloware/shift-php-cs:dev-master

Rename any of your existing files:

.php_cs -> .php-cs-fixer.php

.php_cs.dist -> .php-cs-fixer.dist.php

.php_cs.cache -> .php-cs-fixer.cache

Resources

About

Laravel Shift recommended style config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%