2latlantik/symfony-my-cs

There is no license information available for the latest version (dev-master) of this package.

My coding standard for Symfony project

dev-master 2018-04-05 11:21 UTC

This package is auto-updated.

Last update: 2024-10-22 03:55:40 UTC


README

The goal of this library is to gather a set of process to maintain a good code quality of my symfony projects. Failure to respect some good practices will block the consideration of commit git

I combine the use of different libraries to approve git commit which are:

  • PHP-Lint (A tool to analyze PHP code and to return usage errors)
  • PHP-CS (A tool to control compliance with PSR2 standards here)
  • PHP-CS-FIXER (A tool to control the respect of several coding conventions)

It is also possible to use PHP Mess Detector to further refine the detection of a moderately explicit and error-prone code

Requirements

  • Usage on Symfony4 project
  • Usage with a versioned project with Git

Installation and Usage

I - Install the process of this library

To be able to install the different code verification processes you have to put these lines in the composer.json file.

"scripts" : {
    "my-cs-install": [
        "SymfonyMyCs\\Git\\Hooks\\PostInstall::installHooks"
    ] 
}

Then you can run the installaton script via the command

composer run-script my-cs-install

II - Installation of the Symfony Code Quality executable

Symfony created his own code parser and named it http://cs.sensiolabs.org/ .

You must install it to allow your commit to be validated.

III - Main moment of library actions

At the time of a commit git

PHP Lint and PHPCS check for errors and possibly block commit. At the end php-cs-fix fixes the problems still present. A validated commit is therefore composed of PHP code respecting a set of standards recognized by all.

Execution of PHPMD to further improve the quality of the code

./vendor/bin/phpmd src/Controller/ [format] phpmd

where format : xml|text|html

License

This project is licensed under the MIT License - see the LICENSE.md file for details