2017 © Pedro Peláez
 

composer-plugin grumphp

A composer plugin that enables source code quality checks.

image

phpro/grumphp

A composer plugin that enables source code quality checks.

  • Friday, July 27, 2018
  • by phpro
  • Repository
  • 90 Watchers
  • 2389 Stars
  • 551,461 Installations
  • PHP
  • 376 Dependents
  • 1 Suggesters
  • 203 Forks
  • 43 Open issues
  • 50 Versions
  • 17 % Grown

The README.md

Github Actions AppVeyor Installs Packagist, (*1)

Twitter Join the chat at https://gitter.im/phpro/grumphp, (*2)

GrumPHP

, (*3)

Sick and tired of defending code quality over and over again? GrumPHP will do it for you! This composer plugin will register some git hooks in your package repository. When somebody commits changes, GrumPHP will run some tests on the committed code. If the tests fail, you won't be able to commit your changes. This handy tool will not only improve your codebase, it will also teach your co-workers to write better code following the best practices you've determined as a team., (*4)

GrumPHP has a set of common tasks built-in. You will be able to use GrumPHP with a minimum of configuration., (*5)

We don't want to bore you with all the details, so quick: install it yourself and unleash the power of GrumPHP!, (*6)

Demo

demo, (*7)

Installation

In order for this package to work, you have to make sure following tools are discoverable on the command-line:, (*8)

  • php
  • composer
  • git

This package is a composer plugin and should be installed to your project's dev dependency using composer:, (*9)

Install GrumPHP as a phar without dependencies:, (*10)

composer require --dev phpro/grumphp-shim

Install GrumPHP with dependencies:, (*11)

composer require --dev phpro/grumphp

Install GrumPHP without dependencies and automated git hooks through phive, (*12)

phive install grumphp

When the package is installed, GrumPHP will attach itself to the git hooks of your project. You will see following message in the composer logs:, (*13)

Watch out! GrumPHP is sniffing your commits!, (*14)

GrumPHP will never push you into using a specific task. You can choose the tasks that fit your needs, and activate or deactivate any task in no time! See the suggest section in composer.json., (*15)

Note: GrumPHP will overwrite existing hooks unless you run composer install with --no-plugins or --no-scripts. We do create a backup of your git hook, but it's best to make sure you also have a backup of your custom hooks before you try to install GrumPHP., (*16)

Having trouble installing GrumPHP? Find out how to:, (*17)

Configuration

Some things in GrumPHP can be configured in a grumphp.yml or grumphp.yml.dist or grumphp.dist.yml file in the root of your project (the directory where you run the grumphp command). You can specify a custom config filename and location in composer.json or in the --config option of the console commands., (*18)

# grumphp.yml
grumphp:
    hooks_dir: ~
    hooks_preset: local
    git_hook_variables:
        VAGRANT_HOST_DIR: .
        VAGRANT_PROJECT_DIR: /var/www
        EXEC_GRUMPHP_COMMAND: exec
        ENV: {}
    stop_on_failure: false
    ignore_unstaged_changes: false
    hide_circumvention_tip: false
    process_timeout: 60
    ascii:
        failed: grumphp-grumpy.txt
        succeeded: grumphp-happy.txt
    parallel:
        enabled: true
        max_workers: 32
    fixer:
        enabled: true
        fix_by_default: false
    environment:
        files: []
        variables: {}
        paths: []
    tasks: {}
    testsuites: []
    extensions: []

Details of the configuration are broken down into the following sections., (*19)

Commands

Since GrumPHP is just a CLI tool, these commands can be triggered:, (*20)

Compatibility

GrumPHP works with PHP 5.6 or above., (*21)

This package has been tested with following git clients:, (*22)

  • CLI Unix
  • CLI Mac
  • CLI Windows
  • PhpStorm Git
  • Atlassian SourceTree
  • Syntevo SmartGit

Roadmap

Lots of tasks are already available to make sure your team writes great code. We are always looking to support new tasks. Feel free to log an issue or create a pull request for a task we forgot., (*23)

Are you missing a feature or did you find a bug? Log it in the issue tracker! Want to help out? Feel free to contact us!, (*24)

FAQ

About

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub. Please take a look at our rules before contributing your code., (*25)

License

GrumPHP is licensed under the MIT License., (*26)

The Versions