grumphp

一个PHP代码质量的工具。(A PHP code-quality tool)

Github stars Tracking Chart

Travis
Insight
AppVeyor
Installs
Packagist

Twitter
Freenode
Join the chat at https://gitter.im/phpro/grumphp

GrumPHP

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.

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

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

Demo

Installation

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

  • php
  • composer
  • git

This package is a composer plugin and should be installed to your project's dev dependency using composer:

Install GrumPHP as a phar without dependencies:

composer require --dev phpro/grumphp-shim

Install GrumPHP with dependencies:

composer require --dev phpro/grumphp

Install GrumPHP without dependencies and automated git hooks through phive

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:

Watch out! GrumPHP is sniffing your commits!

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.

Note: GrumPHP will overwrite existing hooks unless you run composer install with --no-plugins or --no-scripts. Be sure to backup your hooks before you try to install GrumPHP.

Having trouble installing GrumPHP? Find out how to:

Configuration

Some things in GrumPHP can be configured in a grumphp.yml or grumphp.yml.dist 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.

# grumphp.yml
parameters:
    hooks_dir: ~
    hooks_preset: local
    git_hook_variables:
         VAGRANT_HOST_DIR: .
         VAGRANT_PROJECT_DIR: /var/www
         EXEC_GRUMPHP_COMMAND: exec
    stop_on_failure: false
    ignore_unstaged_changes: false
    hide_circumvention_tip: false
    process_async_limit: 10
    process_async_wait: 1000
    process_timeout: 60
    ascii:
        failed: grumphp-grumpy.txt
        succeeded: grumphp-happy.txt
    tasks: {}
    testsuites: []
    extensions: []

Details of the configuration are broken down into the following sections.

Commands

Since GrumPHP is just a CLI tool, these commands can be triggered:

Compatibility

GrumPHP works with PHP 5.6 or above.

This package has been tested with following git clients:

  • 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.

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!

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.

License

GrumPHP is licensed under the MIT License.

Main metrics

Overview
Name With Ownerphpro/grumphp
Primary LanguagePHP
Program languagePHP (Language Count: 5)
PlatformBSD, Linux, Mac, Solaris, Windows
License:MIT License
所有者活动
Created At2015-03-18 20:34:36
Pushed At2025-06-04 13:45:36
Last Commit At
Release Count103
Last Release Namev2.13.0 (Posted on 2025-06-04 15:45:17)
First Release Namev0.1.0 (Posted on 2015-03-18 21:37:46)
用户参与
Stargazers Count4.2k
Watchers Count73
Fork Count438
Commits Count2.2k
Has Issues Enabled
Issues Count471
Issue Open Count3
Pull Requests Count550
Pull Requests Open Count7
Pull Requests Close Count106
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private