Skip to content

Rules for PhpCsFixer used in my personal Laravel projects.

Notifications You must be signed in to change notification settings

Fuhrmann/phpcs-fixer-laravel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

Stars

Watchers

Forks

Languages