rossdeane / LaravelGitHooks

A simple laravel package for adding custom git hooks to your laravel projects. Ships with phpunit, phpcs, and eslint

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LaravelGitHooks

Laravel Git Hooks

This is a community project and not an "official" Laravel one

Latest Stable Version Total Downloads License

This package provides a means to add custom git hooks to your laravel project. Easily configure any artisan command to be fired throughout the git-hook process.

By default, this package ships with artisan commands for running:

  • phpunit
  • phpcs
  • eslint

Currently, the following git hooks are supported:

  • pre-commit
  • prepare-commit-msg
  • pre-push

Need one that isn't listed here? Feel free to open a PR!

Install

Via Composer

$ composer require mr-feek/laravel-git-hooks --dev

Edit your laravel project's composer.json so that these hooks are installed for every developer after they use composer.

"post-autoload-dump": [
    ...
    "@php artisan hooks:install"
]

Configuration

  • Publish this package's configuration file: php artisan vendor:publish --provider="Feek\LaravelGitHooks\LaravelGitHooksServiceProvider"
  • Register specific commands to be run in the configuration array. For example, all commands nested within the pre-commit array key will be run prior to a git commit. All commands nested within the pre-push array key will be run prior to a git push. If any of these registered commands fail, then the git action will be prevented.
<?php
return [
    'pre-commit' => [
        'hooks:phpcs --diff --proxiedArguments="-p -n --standard=PSR2"',
        'hooks:eslint --diff --proxiedArguments="--fix --quiet"',
    ],
    'pre-push' => [
        'hooks:phpunit'
    ]
];

Sniffer Commands

The PHPCS, PHPCBF, and ESLINT commands all allow you to pass arguments to the underlying process being executed. You can utilize this via the --proxiedArguments flag. In the code examples above, the following phpcs command will be executed: phpcs -p -n --standard=PSR2

Supported Versions Of Laravel

Laravel ^5.5 is actively supported. Need support for earlier versions of Laravel? Feel free to open a PR

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Wondering how to go about working on a laravel package? See http://laraveldaily.com/how-to-create-a-laravel-5-package-in-10-easy-steps/ and https://laravel.com/docs/5.5/packages

Credits

License

The MIT License (MIT). Please see License File for more information

About

A simple laravel package for adding custom git hooks to your laravel projects. Ships with phpunit, phpcs, and eslint

License:MIT License


Languages

Language:PHP 97.5%Language:Shell 2.5%