Skip to content

Lumen/Laravel wrapper around PHPCS-Fixer package. Used as artisan command

License

Notifications You must be signed in to change notification settings

noitran/cs-fixer-command

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhpCsCommand

Coverage Status Quality Score Software License Latest Version Total Downloads

About

Lumen/Laravel wrapper around PHPCS-Fixer package that allows, using artisan command, easly apply pre-defined coding standards to your laravel or lumen project.

Wrapper uses PHP Coding Standards Fixer package

List of all fixer rules can be found here

Features

  • Adds console command php artisan phpcs:fix that fixes your project to follow standards defined in your config/phpcs.php
  • Adds command to install pre-commit git hook php artisan phpcs:install-hook. After install phpcs:fix will be triggered before each commit and will auto fix your code

Install

  • Install as composer package
$ composer require noitran/cs-fixer-command

Laravel

  • Laravel uses provider auto discovery. Config file can be published using command
$ artisan vendor:publish --provider="Noitran\CsFixer\CsFixerServiceProvider"

Lumen

  • Open your bootstrap/app.php and register as service provider
$app->register(Noitran\CsFixer\CsFixerServiceProvider::class);
  • Config file should be loaded manually in bootstrap/app.php
$app->configure('phpcs');

Usage

  • Publish phpcs and change if necessary, run command for inspection php artisan phpcs:fix

  • Hook installation can be done using command php artisan phpcs:install-hook

  • Hook install command can be added into composer.json as post-install command, so that, at example, other team members will get pre-commit hook when installing composer dependencies at first time.

Example: Adding as composer post-install command

{
    "name": "laravel/lumen",
    "require": {
        ...
    },
    "autoload": {
        ...
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan phpcs:install-hook"
        ],
        "post-update-cmd": [
            ...
        ]
    }
}

About

Lumen/Laravel wrapper around PHPCS-Fixer package. Used as artisan command

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •