hellochef-me/php-styles

HelloChef shared PHP style rules for PHP-CS-Fixer

1.0.9 2023-02-01 12:13 UTC

This package is auto-updated.

Last update: 2024-04-29 14:53:29 UTC


README

HelloChef PHP Code Styles

Shared PHP style rules for PHP-CS-Fixer

Latest Version on Packagist Total Downloads MIT Licensed

Install the package

composer require hellochef-me/php-styles

Create and setup config file in project root .php-cs-fixer.php

<?php

return HelloChef\CodeStyles\PhpStyles::style();

Optionally, you may add php-cs-fixer cache file to your .gitignore

// .gitignore
.php-cs-fixer.cache

Format code on demand

  • Format the whole project
vendor/bin/php-cs-fixer fix .
  • Format specific file
vendor/bin/php-cs-fixer fix Path/To/ExampleFileToFormat.php

Format code on commit

Add the following scripts to your composer.json

"scripts": {
    "post-update-cmd": [
      "cp vendor/hellochef-me/php-styles/pre-commit .git/hooks/pre-commit",
      "chmod a+x .git/hooks/pre-commit"
    ],
    "post-install-cmd": [
      "cp vendor/hellochef-me/php-styles/pre-commit .git/hooks/pre-commit",
      "chmod a+x .git/hooks/pre-commit"
    ],
},