It is easy to configure and activate tasks in GrumPHP. Tasks live under their own namespace in the parameters part. To activate a task, it is sufficient to add an empty task configuration:
# grumphp.yml
parameters:
tasks:
ant: ~
atoum: ~
behat: ~
brunch: ~
clover_coverage: ~
codeception: ~
composer: ~
composer_normalize: ~
composer_require_checker: ~
composer_script: ~
deptrac: ~
doctrine_orm: ~
ecs: ~
file_size: ~
gherkin: ~
git_blacklist: ~
git_branch_name: ~
git_commit_message: ~
grunt: ~
gulp: ~
infection: ~
jsonlint: ~
kahlan: ~
make: ~
npm_script: ~
paratest: ~
phan: ~
phing: ~
php7cc: ~
phpcpd: ~
phpcs: ~
phpcsfixer: ~
phpcsfixer2: ~
phplint: ~
phpmd: ~
phpmnd: ~
phpparser: ~
phpspec: ~
phpstan: ~
phpunit: ~
phpunitbridge: ~
phpversion: ~
progpilot: ~
psalm: ~
robo: ~
securitychecker: ~
shell: ~
twigcs: ~
xmllint: ~
yamllint: ~
Every task has it's own default configuration. It is possible to overwrite the parameters per task.
- Ant
- Atoum
- Behat
- Brunch
- Clover Coverage
- Codeception
- Composer
- Composer Normalize
- Composer Require Checker
- Composer Script
- Doctrine ORM
- Ecs EasyCodingStandard
- File size
- Deptrac
- Gherkin
- Git blacklist
- Git branch name
- Git commit message
- Grunt
- Gulp
- Infection
- JsonLint
- Kahlan
- Make
- NPM script
- Paratest
- Phan
- Phing
- Php7cc
- PhpCpd
- Phpcs
- PHP-CS-Fixer
- PHP-CS-Fixer 2
- PHPLint
- PhpMd
- PhpMnd
- PhpParser
- Phpspec
- PHPStan
- Phpunit
- Phpunit bridge
- PhpVersion
- Progpilot
- Psalm
- Robo
- Security Checker
- Shell
- TwigCs
- XmlLint
- YamlLint
Every task has a pre-defined metadata
key on which application specific options can be configured.
For example:
# grumphp.yml
parameters:
tasks:
anytask:
metadata:
blocking: true
priority: 0
priority
Default: 0
This option can be used to specify the order in which the tasks will be executed. The higher the priority, the sooner the task will be executed.
blocking
Default: true
This option can be used to make a failing task non-blocking. By default all tasks will be marked as blocking. When a task is non-blocking, the errors will be displayed but the tests will pass.
It is very easy to configure your own project specific task.
You just have to create a class that implements the GrumPHP\Task\TaskInterface
.
Next register it to the service manager and add your task configuration:
# grumphp.yml
parameters:
tasks:
myConfigKey:
config1: config-value
services:
task.myCustomTask:
class: My\Custom\Task
arguments:
- '@config'
tags:
- {name: grumphp.task, config: myConfigKey}
Note: You do NOT have to add the main and task configuration. This example just shows you how to do it. You're welcome!
You just registered your custom task in no time! Pretty cool right?!
In some cases you might want to run the same task but with different configuration. The suggested way of doing this, is by registering the existing task with a different name. Configuration of the additional task will look like this:
# grumphp.yml
parameters:
tasks:
phpcsfixer2:
allow_risky: true
path_mode: intersection
phpcsfixer2_typo3:
allow_risky: true
config: .typo3.php_cs
path_mode: intersection
services:
task.phpcsfixer2_typo3:
class: Acme\Typo3\ConventionsChecker\Task\PhpCsFixerV2Typo3
arguments:
- '@config'
- '@process_builder'
- '@async_process_runner'
- '@formatter.phpcsfixer'
tags:
- {name: grumphp.task, config: phpcsfixer2_typo3}
Since we currently match the name based on the task name, you'll also have to create a new task class:
<?php
// Acme/Typo3/ConventionsChecker/Task/PhpCsFixerV2Typo3.php
namespace Acme\Typo3\ConventionsChecker\Task;
use GrumPHP\Task\PhpCsFixerV2;
class PhpCsFixerV2Typo3 extends PhpCsFixerV2
{
public function getName()
{
return 'phpcsfixer2_typo3';
}
}