<commit_before>php-git-hooks
=============
[![Build Status](https://travis-ci.org/bruli/php-git-hooks.svg?branch=master)](https://travis-ci.org/bruli/php-git-hooks)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bruli/php-git-hooks/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bruli/php-git-hooks/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/bruli/php-git-hooks/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/bruli/php-git-hooks/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/bruli/php-git-hooks/v/stable.svg)](https://packagist.org/packages/bruli/php-git-hooks) [![Total Downloads](https://poser.pugx.org/bruli/php-git-hooks/downloads)](https://packagist.org/packages/bruli/php-git-hooks) [![Latest Unstable Version](https://poser.pugx.org/bruli/php-git-hooks/v/unstable.svg)](https://packagist.org/packages/bruli/php-git-hooks) [![License](https://poser.pugx.org/bruli/php-git-hooks/license.svg)](https://packagist.org/packages/bruli/php-git-hooks)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/584eb4ce-7de2-4bb0-9728-5e8be8e4ca3f/mini.png)](https://insight.sensiolabs.com/projects/584eb4ce-7de2-4bb0-9728-5e8be8e4ca3f)

Git hooks for PHP projects.

Library based in git hook scripts for PHP projects.

[Original scripts](http://carlosbuenosvinos.com/write-your-git-hooks-in-php-and-keep-them-under-git-control/)

## Installation

### Step 1: Composer

You must add the following line to the `composer.json` file to use with Symfony 3.0:

```json
{
    "require-dev": {
        "bruli/php-git-hooks": "~3.0"
    }
}
```
You can use "~2.0" for Symfony version 2.X.

Or you can write in your console:

```bash
$ composer require bruli/php-git-hooks --dev
```

If you don't have composer, you need download the  binary file and run it:

```bash
wget http://getcomposer.org/composer.phar
# or
curl -O http://getcomposer.org/composer.phar

php composer.phar install
```

## Step 2: Configuration
### Composer configuration.
After download all repositories, composer ask you about configuration.

<img style="border:1px solid #ccc; padding:1px" src="https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/composer-config.png" />

### Composer configuration in Symfony2 projects.

In Symfony2 projects you need add this lines in your composer.json:

```json
"scripts": {
    "post-install-cmd": [
      ...other lines...
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ],
    "post-update-cmd": [
      ...other lines...
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ]
```

**Important: To use 2.X version you need symfony 2.7 version.**

### Bin directory configuration.

If your project haven't a "bin" directory, you can add this in your compose.json file.

```json
 "config": {
        "bin-dir": "bin"
    }
```

**Note: Not necessary for Symfony projects.**

### Manual config file for git hooks.
You can configure php-git-hooks, creating a php-git-hooks.yml file with...

```yaml
pre-commit:
  enabled: true
  execute:
    php-cs-fixer:
        enabled:  true
        levels:
            psr0:       true
            psr1:       true
            psr2:       true
            symfony:    true
    phpunit:
        enabled:     true
        random-mode: true
    phplint:         true
    phpcs:
        enabled:     true
        standard:    PSR2
    phpmd:           true
    composer:        true
  message: 
    right-message: 'HEY, GOOD JOB!!'
    error-message: 'FIX YOUR CODE!!'
commit-msg:
    enabled: true
    regular-expression: '#[0-9]{2,7}'
```

... or you can copy php-git-hooks.yml.sample from vendor/bruli/php-git-hooks.

### Update from v1.3.*

Php-cs-fixer configuration in php-git-hooks.yml file, is not compatible with 2.0 version. 
You should remove php-cs-fixer entry and execute "composer install".

Most easy way to update is delete php-git-hooks.yml and execute "composer install". You will see all the configuration questions again.

### Config file for phpunit.
If you want use phpunit tool, you must create a phpunit.xml.dist in your project root directory. 
Alternatively you can copy from vendor/bruli/php-git-hooks/phpunit.xml.dist in your project root directory.

### Config file for phpmd.
The same case that phpunit. You must create a PmdRules.xml in your project root directory or copy from php-git-hook directory.

## Step 3: Enabling hooks.

The most easy way to enable hook is copy hook file into your .git/hooks directory.

#For pre-commit hook:

You can enable this hooks with composer or manually executing

```bash
 $cp vendor/bruli/php-git-hooks/hooks/pre-commit .git/hooks
```

#For commit-msg hook:

```bash
 $cp vendor/bruli/php-git-hooks/hooks/commit-msg .git/hooks
```

### execute.
####Valid pre-commit.
<img style="border:1px solid #ccc; padding:1px" src="https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit.png" />
####Fail pre-commit.
<img style="border:1px solid #ccc; padding:1px" src="https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit-failed.png" />

## Credits

* <NAME> ([@brulics](https://twitter.com/brulics))
* [All contributors](https://github.com/bruli/php-git-hooks/graphs/contributors)

## License

php-git-hooks is released under the MIT License. See the bundled LICENSE file for details.<commit_msg>Updating markdown installation instructions Fix: #50<commit_after>php-git-hooks
=============
[![Build Status](https://travis-ci.org/bruli/php-git-hooks.svg?branch=master)](https://travis-ci.org/bruli/php-git-hooks)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/bruli/php-git-hooks/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/bruli/php-git-hooks/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/bruli/php-git-hooks/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/bruli/php-git-hooks/?branch=master)
[![Latest Stable Version](https://poser.pugx.org/bruli/php-git-hooks/v/stable.svg)](https://packagist.org/packages/bruli/php-git-hooks) [![Total Downloads](https://poser.pugx.org/bruli/php-git-hooks/downloads)](https://packagist.org/packages/bruli/php-git-hooks) [![Latest Unstable Version](https://poser.pugx.org/bruli/php-git-hooks/v/unstable.svg)](https://packagist.org/packages/bruli/php-git-hooks) [![License](https://poser.pugx.org/bruli/php-git-hooks/license.svg)](https://packagist.org/packages/bruli/php-git-hooks)
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/584eb4ce-7de2-4bb0-9728-5e8be8e4ca3f/mini.png)](https://insight.sensiolabs.com/projects/584eb4ce-7de2-4bb0-9728-5e8be8e4ca3f)

Git hooks for PHP projects.

Library based in git hook scripts for PHP projects.

[Original scripts](http://carlosbuenosvinos.com/write-your-git-hooks-in-php-and-keep-them-under-git-control/)

## Installation

### Step 1: Composer

You must add the following line to the `composer.json` file to use with Symfony 3.0:

```json
{
    "require-dev": {
        "bruli/php-git-hooks": "~3.0"
    }
}
```
You can use "~2.0" for Symfony version 2.X.

Or you can write in your console:

```bash
$ composer require bruli/php-git-hooks --dev
```

If you don't have composer, you need download the  binary file and run it:

```bash
$ wget http://getcomposer.org/composer.phar
# or
$ curl -O http://getcomposer.org/composer.phar

$ php composer.phar install
```

## Step 2: Configuration

### Using Composer

First, you will need to add the following lines to your `composer.json`

```json
"scripts": {
    "post-install-cmd": [
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ],
    "post-update-cmd": [
      "PhpGitHooks\\Application\\Composer\\ConfiguratorScript::buildConfig"
    ]
}
```

Then, launch `$ composer install` and composer should ask you about configuration

<img style="border:1px solid #ccc; padding:1px" src="https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/composer-config.png" />

**Important:** To use 2.X version you need symfony 2.7 version.

### Bin directory configuration.

If your project doesn't have a "bin/" directory, you can add this in your `composer.json` file.

```json
"config": {
    "bin-dir": "bin"
}
```

**Note:** This is not necessary for Symfony projects.

### Manual config file for git hooks.

You can configure php-git-hooks, creating a php-git-hooks.yml file with...

```yaml
pre-commit:
  enabled: true
  execute:
    php-cs-fixer:
        enabled:  true
        levels:
            psr0:       true
            psr1:       true
            psr2:       true
            symfony:    true
    phpunit:
        enabled:     true
        random-mode: true
    phplint:         true
    phpcs:
        enabled:     true
        standard:    PSR2
    phpmd:           true
    composer:        true
  message:
    right-message: 'HEY, GOOD JOB!!'
    error-message: 'FIX YOUR CODE!!'
commit-msg:
    enabled: true
    regular-expression: '#[0-9]{2,7}'
```

... or you can copy php-git-hooks.yml.sample from vendor/bruli/php-git-hooks.

### Update from v1.3.*

Php-cs-fixer configuration in php-git-hooks.yml file, is not compatible with 2.0 version.
You should remove php-cs-fixer entry and execute "composer install".

Most easy way to update is delete php-git-hooks.yml and execute "composer install". You will see all the configuration questions again.

### Config file for phpunit.

If you want use phpunit tool, you must create a phpunit.xml.dist in your project root directory.
Alternatively you can copy from vendor/bruli/php-git-hooks/phpunit.xml.dist in your project root directory.

### Config file for phpmd.

The same case that phpunit. You must create a PmdRules.xml in your project root directory or copy from php-git-hook directory.

## Step 3: Enabling hooks.

The most easy way to enable hook is copy hook file into your .git/hooks directory.

#For pre-commit hook:

You can enable this hooks with composer or manually executing

```bash
$ cp vendor/bruli/php-git-hooks/hooks/pre-commit .git/hooks
```

#For commit-msg hook:

```bash
$ cp vendor/bruli/php-git-hooks/hooks/commit-msg .git/hooks
```

### execute.

####Valid pre-commit.

<img style="border:1px solid #ccc; padding:1px" src="https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit.png" />

####Fail pre-commit.

<img style="border:1px solid #ccc; padding:1px" src="https://raw.githubusercontent.com/bruli/php-git-hooks/master/Resources/docs/images/pre-commit-failed.png" />

## Credits

* <NAME> ([@brulics](https://twitter.com/brulics))
* [All contributors](https://github.com/bruli/php-git-hooks/graphs/contributors)

## License

php-git-hooks is released under the [MIT License](https://opensource.org/licenses/MIT). See the bundled LICENSE file for details.
{'fraction_non_alphanumeric': 0.14873301505692252, 'fraction_numerical': 0.012302607418288652, 'mean_word_length': 3.5962025316455697, 'pattern_counts': {'":': 14, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 43, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6212468', 'n_tokens_mistral': 3836, 'n_tokens_neox': 3720, 'n_words': 865}