PHPackages                             staempfli/typo3-conventions-checker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. staempfli/typo3-conventions-checker

ActiveLibrary[Testing &amp; Quality](/categories/testing)

staempfli/typo3-conventions-checker
===================================

Enforces code quality guidelines for TYPO3 CMS projects

0.4.0(7y ago)1853GPL-3.0PHPPHP ^7.0

Since Sep 25Pushed 7y ago8 watchersCompare

[ Source](https://github.com/staempfli/typo3-conventions-checker)[ Packagist](https://packagist.org/packages/staempfli/typo3-conventions-checker)[ RSS](/packages/staempfli-typo3-conventions-checker/feed)WikiDiscussions develop Synced yesterday

READMEChangelogDependencies (3)Versions (10)Used By (0)

TYPO3 Conventions Checker
=========================

[](#typo3-conventions-checker)

What does it do?
----------------

[](#what-does-it-do)

This package lets you automatically test any changed code against the [TYPO3 file formatting requirements](https://docs.typo3.org/typo3cms/CodingGuidelinesReference/PhpFileFormatting/GeneralRequirementsForPhpFiles/Index.html) right before you commit your changes. It also forces you to keep the commit messages tidy, according to the [TYPO3 contribution workflow](https://docs.typo3.org/typo3cms/ContributionWorkflowGuide/GitSetup/CommitMessageFormat.html). There are some checks we're leaving out, though, as the commit message structure applies to TYPO3 core contributions and we're not usually committing to the core repository in our projects, eh.

This works via Git hooks, so every time you type 'git commit ...', the configured GrumPHP tasks get fired.

The package itself doesn't do much, honestly. :) It provides some configuration and requires some dependencies to get your code quality and conventions checks set up in no time.

But how does it do it?
----------------------

[](#but-how-does-it-do-it)

Pretty simple. It requires [GrumPHP](https://github.com/phpro/grumphp)which hits up the [PHP Coding Standards Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer)and well as the [PHP Mess Detector](https://github.com/phpmd/phpmd)on each and every commit of yours. Only the files you're trying to commit are getting checked for any coding standards violations or code messes.

Installing
----------

[](#installing)

### Prerequisites / TYPO3 project setup

[](#prerequisites--typo3-project-setup)

This package expects you work with a composer-based TYPO3 setup, having a (probably versioned) composer manifest outside your public html directory called 'web' (though you may of course reconfigure this directory's name). Something along the lines of:

```
- your-typo3-project/
  - bin
  - vendor
  (...)
  - composer.json
  - web
    - fileadmin
    - typo3
    - typo3conf
    (...)

```

- Reference the GrumPHP configuration file (`grumphp.yml`) in the "extra" section of your root composer manifest:

```
(...)
  "extra": {
    "grumphp": {
      "config-default-path": "vendor/staempfli/typo3-conventions-checker/conf/grumphp.yml"
    }
  }
```

(Alternatively, you can create a custom grumphp.yml file in your git root directory, this will work as well).

- Require this package via composer `composer require --dev "staempfli/typo3-conventions-checker"`
- Commit changes to your project. All checks will be run automagically on commit.

Options and Customizing
-----------------------

[](#options-and-customizing)

### Default configuration

[](#default-configuration)

Per default, this package uses

- a [php-cs-fixer](./conf/PhpCsFixer.php) configuration corresponding to the [TYPO3 core php-cs-fixer configuration](https://github.com/TYPO3/TYPO3.CMS/blob/master/Build/.php_cs)
- Git commit message rules, mainly integrating the [TYPO3 core commit message format](https://docs.typo3.org/typo3cms/ContributionWorkflowGuide/GitSetup/CommitMessageFormat.html), excluding the ones specific to the TYPO3 core contribution workflow such as the 'Releases' and/or 'Change-Id' requirements
- ([see full configuration in /conf/grumphp.yml](./conf/grumphp.yml))

### Override (i.e. 'extend') configuration

[](#override-ie-extend-configuration)

For this to work, you need to create your own grumphp.yml in your git root directory according to the [GrumPHP](https://github.com/phpro/grumphp) configuration. In there, you may reference this package's grumphp configuration and override the settings.

**Important notice on inheritance**: To my knowledge, it is not possible to recursively inherit task settings, meaning: **you override one property/setting of a task (see example below), you need to re-define all tasks and their settings**. [See the grumphp configuration provided for extensions](./conf/grumphp-extensions.yml).

#### Example 1: Reconfiguring the git commit message restrictions

[](#example-1-reconfiguring-the-git-commit-message-restrictions)

Let's say you want to limit the git commit message length to 42 characters. Update your `grumphp.yml` from

```
imports:
    - { resource: vendor/staempfli/typo3-conventions-checker/conf/grumphp.yml }
```

to something like

```
imports:
    - { resource: vendor/staempfli/typo3-conventions-checker/conf/grumphp.yml }
parameters:
    tasks:
        git_commit_message:
            max_subject_width: 42

        (other tasks' configuration with or without customization)
```

#### Example 2: Customizing the php-cs-fixer configuration

[](#example-2-customizing-the-php-cs-fixer-configuration)

Like in the first example: reconfigure this via the grumphp configuration. This time though, reference a different (your own) php-cs-fixer configuration:

```
imports:
    - { resource: vendor/staempfli/typo3-conventions-checker/conf/grumphp.yml }
parameters:
    tasks:
        phpcsfixer2:
            config: 'your/own/PhpCsFixer/conf.php'

        (other tasks' configuration with or without customization)
```

Initializing extensions
-----------------------

[](#initializing-extensions)

Let's say, you maintain an extension 'mynews' and of course, you want the code of 'mynews' to comply with some coding standards as well. You're working on the main project, where 'mynews' is included as a dependency but you'll probably introduce changes to 'mynews' while working on the main project. But, because 'mynews' is its own git repository, it doesn't get checked by GrumPHP automatically if you just initialized GrumPHP on your main project as described above.

```
- main-typo3-project/
  - composer.json
  - web
    - fileadmin
    - typo3
    - typo3conf
      - ext
        - mynews
