labelworx/shift-styles

PHP code linter using Laravel Shift ruleset and PHP-CS-Fixer

1.0.2 2020-10-10 09:46 UTC

This package is auto-updated.

Last update: 2024-05-10 17:50:34 UTC


README

This package allows you to quickly run the Laravel Shift linter commands locally using php artisan shift.

Using PHP CS Fixer and a ruleset created by Laravel Shift, this makes linting your Laravel project simple and adhere to "The Laravel Way".

Your can find the official ruleset used in this package in this gist.

Installation

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

composer require --dev labelworx/shift-styles

Setup

This command will require a .php_cs.dist configuration file for PHP CS Fixer to be available in your project root directory.

You can create this file using the command.

php artisan shift:setup

This file contains the default Laravel folder structure. These are the folders that will be scanned by PHP CS Fixer. You will need to add additional paths to this file if your project structure is different from that listed below.

A typical Laravel Project includes these directories:

<?php

$finder = PhpCsFixer\Finder::create()
  ->in([
    __DIR__ . '/app',
    __DIR__ . '/config',
    __DIR__ . '/database',
    __DIR__ . '/resources',
    __DIR__ . '/routes',
    __DIR__ . '/tests',
  ]);

return Labelworx\styles($finder);

PHP CS Fixer uses a cache file to speed up usage. You are recommended that to add the .php_cs.cache to you .gitignore file.

Usage

To run and fix files -

php artisan shift

Resources