drupol / php-conventions
PHP conventions based on Grumphp tasks.
Fund package maintenance!
drupol
Installs: 41 153
Dependents: 56
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 1
Requires
- php: ^7.3 || ^7.4 || ^8
- drupol/phpcsfixer-configs-php: ^1.0.31
- ergebnis/composer-normalize: ^2.11
- php-parallel-lint/php-parallel-lint: ^1.2.0
- phpro/grumphp: 1.3.*
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12.63
- phpstan/phpstan-deprecation-rules: ^0.12
- sensiolabs/security-checker: ^6
- squizlabs/php_codesniffer: ^3.5.8
- symfony/yaml: ^3 || ^4 || ^5
Suggests
- friendsoftwig/twigcs: Checkstyle automation for Twig
- phpstan/phpstan-strict-rules: PHPStan rules providing extra strict and opinionated code style.
README
PHP conventions
This development tool provides a pre-defined configuration for GrumPHP with the following checks enabled:
- Security Checker (sensiolabs/security-checker),
- composer.json validation,
- composer.json normalization (ergebnis/composer-normalize),
- YAML Lint,
- JSON Lint,
- PHP Lint (php-parallel-lint/php-parallel-lint),
- Twig CS (friendsoftwig/twigcs),
- PHP CS Fixer checks and fixes (PSR12 or some other custom ones),
- PHP CS (PHP CS),
- PHP Stan (PHPStan)
The package provides a default configuration for each task, and it's customizable at will through a simple configuration file.
The package will install the required dependencies, so it works out of the box.
Tasks can be also added or skipped according to your need.
Installation
composer require drupol/php-conventions:^1.8 --dev
If you're not using GrumPHP
Manually add to your composer.json
file
"extra": { "grumphp": { "config-default-path": "vendor/drupol/php-conventions/config/php71/grumphp.yml" } }
Replace the string php71
with the minimal version of php you want to support.
Current choices are:
psr12
php71
php73
If you're using GrumPHP already
Edit the file grumphp.yml.dist
or grumphp.yml
and add on the top it:
imports: - { resource: vendor/drupol/php-conventions/config/php71/grumphp.yml }
To add an extra Grumphp task:
imports: - { resource: vendor/drupol/php-conventions/config/php71/grumphp.yml } parameters: extra_tasks: infection: threads: 1 test_framework: phpspec configuration: infection.json.dist min_msi: 60 min_covered_msi: 60 skip_tasks: - phpcs
In conjunction with extra_tasks
, use skip_tasks
to skip tasks if needed.
Testsuites
Do you want to specify some pre-defined tasks you want to run? It is easy to configure and run custom testsuites.
Available testsuites are:
- cs (composer, composer_normalize, yamllint, phplint, twigcs, phpcsfixer, phpcs)
- static-analysis (phpstan)
- security (securitychecker)
To run a particular testsuite:
./vendor/bin/grumphp run --testsuite=cs
Contributing
See the file CONTRIBUTING.md but feel free to contribute to this library by sending Github pull requests.