/php-conventions

Primary LanguagePHPMIT LicenseMIT

Latest Stable Version GitHub stars Total Downloads License

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:

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