2017 © Pedro Peláez
 

application phpcc

A PHP code checks automation tool that can be used as git pre-commit hook.

image

alfonsomthd/phpcc

A PHP code checks automation tool that can be used as git pre-commit hook.

  • Friday, December 15, 2017
  • by alfonsomthd
  • Repository
  • 0 Watchers
  • 0 Stars
  • 253 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP Code Checker

CLI tool to run PHP code checks that can be used as git pre-commit hook., (*1)

See Usage section below., (*2)

Installation

Install composer:, (*3)

curl -LsS https://getcomposer.org/installer -o composer-setup.php
php composer-setup.php && rm composer-setup.php
mkdir -p ~/.local/bin
mv composer.phar ~/.local/bin/composer
sudo ln -sf ~/.local/bin/composer /usr/local/bin/composer

Install PHP Code Checker:, (*4)

composer global require alfonsomthd/phpcc
sudo ln -sf $(composer global config --absolute vendor-dir 2>/dev/null)/alfonsomthd/phpcc/phpcc /usr/local/bin/phpcc

Configuration

The following tasks are executed:, (*5)

  • Syntax check (lint).
  • Code style fixing with php-cs-fixer.
  • Tests execution -if there are any- with PHPUnit when checking files in staging area.
  • Code analysis with phpmd.

If you want to override the default configuration, create a file in your project root named phpcc.json with the following structure (example with default configuration values):, (*6)

{
    "ignore": [],
    "checks": {
        "php-cs-fixer": {
            "rules": "@PSR2,@PSR1,-psr0",
            "fix": true
        },
        "phpmd": {
            "ruleset": "",
            "minimumpriority": 2
        },
        "phpunit": {
            "config-file": "",
            "allow-display": true
        }
    }
}

Configuration fields:, (*7)

  • ignore, (*8)

    Like git, you can ignore files/folders adding the relative path in this field. Also, you can use the prefix ! to negate the path and not ignore the file/folder., (*9)

    For example, the following configuration ignore all the project except the directories src and tests:, (*10)

    "ignore": [".", "!src", "!tests"]
  • checks, (*11)

    • php-cs-fixer, (*12)

      • rules: If not set, default value (see example above) will be used. See php-cs-fixer documentation for allowed values.
      • fix: If not set, default value is true only when cheking files in git staging area. Option --fix-cs overrides everything else.
    • phpmd, (*13)

      • ruleset: Relative path to rule set filename or a comma-separated string of rule set filenames. If not set, phpcc rule set phpmdRuleSet.xml will be used. See phpmd documentation for rule set filenames already provided by phpmd.
      • minimumpriority: If not set, default value (see example above) will be used. See phpmd documentation.
    • phpunit, (*14)

      • config-file: Relative path to phpunit.xml. If you want to generate a new configuration file, run: phpunit --generate-configuration
      • allow-display: false to disable progress display. Allowed by default. In case of errors, this setting will be ignored and all output will be displayed.

Usage

The tool must be run in your project's root directory (the directory that contains your project's composer.json):, (*15)

cd <YOUR_PROJECT_ROOT_DIRECTORY>

Display the help message:, (*16)

phpcc -h

To check a file or directory, pass it as first argument (e.g.):, (*17)

phpcc src

Check a file or directory fixing code style errors:, (*18)

phpcc src --fix-cs

To check PHP files in git staging area:, (*19)

phpcc

To run it on git pre-commit, do the following:, (*20)

ln -sf /usr/local/bin/phpcc .git/hooks/pre-commit

The Versions

15/12 2017

dev-master

9999999-dev https://bitbucket.org/alfonsomthd/phpcc

A PHP code checks automation tool that can be used as git pre-commit hook.

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Alfonso M.H.

git pre-commit php code check automation tool phpcc

15/12 2017

2.0

2.0.0.0 https://bitbucket.org/alfonsomthd/phpcc

A PHP code checks automation tool that can be used as git pre-commit hook.

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Alfonso M.H.

git pre-commit php code check automation tool phpcc

25/06 2017

1.0

1.0.0.0 https://bitbucket.org/alfonsomthd/phpcc

A PHP code checks automation tool that can be used as git pre-commit hook.

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

by Alfonso M.H.

git pre-commit php code check automation tool phpcc