Fuhrmann / phpcs-fixer-laravel

Rules for PhpCsFixer used in my personal Laravel projects.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Instructions

Add this repository to composer.json file:

{
    "repositories": [
        {
            "url": "https://github.com/Fuhrmann/phpcs-fixer-laravel",
            "type": "git"
        }
    ]
}
{
    "require-dev": {
        "fuhrmann/phpcs-fixer-laravel": "master"
    }
}

Add the command to the scripts section:

{
    "scripts": {
        "fix-style": "vendor/bin/php-cs-fixer fix --config=vendor/fuhrmann/phpcs-fixer-laravel/.php_cs.dist --ansi"
    }
}

Then execute the fixer with: composer fix-style.

Composer (docker) hooks

Assuming you have a container just for composer.

If you want to fix the styles on every commit, you can:

{
       "extra": {
           "hooks": {
               "pre-commit": [
                   "docker-compose run --rm composer fix-style"
               ],
               "...": "..."
           }
       }
   }

Declare in the scripts section so the hooks keep updated:

{
    "scripts": {
        "cghooks": "vendor/bin/cghooks",
        "post-install-cmd": "docker-compose run --rm composer cghooks add --ignore-lock",
        "post-update-cmd": "docker-compose run --rm composer cghooks update"
    }
}

Reference

Credits

Based on this gist with a few changes.

About

Rules for PhpCsFixer used in my personal Laravel projects.


Languages

Language:PHP 100.0%