drupol / php-conventions
PHP conventions based on GrumPHP.
Fund package maintenance!
drupol
Installs: 122 231
Dependents: 57
Suggesters: 0
Security: 0
Stars: 7
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: >= 8.1
- drupol/phpcsfixer-configs-php: ^2
- ergebnis/composer-normalize: ^2
- friendsoftwig/twigcs: ^5 || ^6
- loophp/grumphp-license-task: ^1
- maglnet/composer-require-checker: ^3 || ^4
- php-parallel-lint/php-parallel-lint: ^1
- phpro/grumphp: ^1 || ^2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1
- phpstan/phpstan-deprecation-rules: ^1.0
- symfony/yaml: ^6.4 || ^7
- vimeo/psalm: ^5
Suggests
- phpstan/phpstan-strict-rules: PHPStan rules providing extra strict and opinionated code style.
This package is auto-updated.
Last update: 2024-12-09 10:30:26 UTC
README
PHP conventions
Description
A developer tool which provides a pre-defined GrumPHP configuration tailored specifically for PHP development.
Features
The default GrumPHP configuration ships with the following checks:
- License file creation,
- Composer Require Checker,
composer.json
validation,- composer.json normalization,
- YAML Lint,
- JSON Lint,
- PHP Lint,
- Twig CS,
- PHP CS Fixer checks (Based on PSR12),
- PHP CS,
- PHPStan.
- PSalm,
It provides a default configuration for each task, and they are customizable at will through a simple YAML configuration file.
Tasks can be also added or skipped according to your need.
Installation
composer require drupol/php-conventions --dev
If you're not using GrumPHP
Manually add to your composer.json
file
"extra": { "grumphp": { "config-default-path": "vendor/drupol/php-conventions/config/php73/grumphp.yml", }, }
Replace the string php73
with the minimal version of PHP you want to support.
Current choices are:
psr12
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/php73/grumphp.yml }
To add an extra GrumPHP task:
imports: - { resource: vendor/drupol/php-conventions/config/php73/grumphp.yml } parameters: extra_tasks: infection: threads: 1 test_framework: phpspec configuration: infection.json.dist min_msi: 60 min_covered_msi: 60 skip_tasks: - phpcsfixer
In conjunction with extra_tasks
, use skip_tasks
to skip tasks if needed.
Usage
Basic usage
vendor/bin/grumphp run
This will run all the pre-configured tasks.
Advanced usage
If you're willing to specify a group of tasks only, you can use the pre-defined test suites.
Available test-suites are:
cs
- license
- composer_require_checker
- composer
- composer_normalize
- yamllint
- jsonlint
- phplint
- twigcs
- phpcsfixer
static-analysis
- phpstan
- psalm
To run a particular test-suite:
vendor/bin/grumphp run --testsuite=cs
To run particular tasks:
vendor/bin/grumphp run --tasks=phpcsfixer,phpstan
Contributing
Report bug on the issue tracker.
See the file CONTRIBUTING.md but feel free to contribute to this library by sending Github pull requests.
Changelog
See CHANGELOG.md for a changelog based on git commits.
For more detailed changelogs, please check the release changelogs.
To generate the changelog, use the following command:
docker-compose run auto_changelog --commit-limit false --hide-credit --sort-commits date-desc --breaking-pattern ""BREAKING CHANGE: yes" --template keepachangelog -u