installation.rst 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ============
  2. Installation
  3. ============
  4. Requirements
  5. ------------
  6. PHP needs to be a minimum version of PHP 7.4.
  7. Installation
  8. ------------
  9. Locally
  10. ~~~~~~~
  11. Download the `php-cs-fixer.phar`_ file and store it somewhere on your computer.
  12. Globally (manual)
  13. ~~~~~~~~~~~~~~~~~
  14. You can run these commands to easily access latest ``php-cs-fixer`` from anywhere on
  15. your system:
  16. .. code-block:: console
  17. wget https://cs.symfony.com/download/php-cs-fixer-v3.phar -O php-cs-fixer
  18. or with specified version:
  19. .. code-block:: console
  20. wget https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/releases/download/v3.13.0/php-cs-fixer.phar -O php-cs-fixer
  21. or with curl:
  22. .. code-block:: console
  23. curl -L https://cs.symfony.com/download/php-cs-fixer-v3.phar -o php-cs-fixer
  24. then:
  25. .. code-block:: console
  26. sudo chmod a+x php-cs-fixer
  27. sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
  28. Then, just run ``php-cs-fixer``.
  29. Globally (Composer)
  30. ~~~~~~~~~~~~~~~~~~~
  31. To install PHP CS Fixer, `install Composer <https://getcomposer.org/download/>`_ and issue the following command:
  32. .. code-block:: console
  33. composer global require friendsofphp/php-cs-fixer
  34. Then make sure you have the global Composer binaries directory in your ``PATH``. This directory is platform-dependent, see `Composer documentation <https://getcomposer.org/doc/03-cli.md#composer-home>`_ for details. Example for some Unix systems:
  35. .. code-block:: console
  36. export PATH="$PATH:$HOME/.composer/vendor/bin"
  37. Globally (homebrew)
  38. ~~~~~~~~~~~~~~~~~~~
  39. .. code-block:: console
  40. brew install php-cs-fixer
  41. Locally (PHIVE)
  42. ~~~~~~~~~~~~~~~
  43. Install `PHIVE <https://phar.io>`_ and issue the following command:
  44. .. code-block:: console
  45. phive install php-cs-fixer # use `--global` for global install
  46. GitHub Action (Docker)
  47. ~~~~~~~~~~~~~~~~~~~~~~
  48. To integrate php-cs-fixer as check into a GitHub Action step, you can use a configuration like this:
  49. .. code-block:: yaml
  50. - name: PHP-CS-Fixer
  51. uses: docker://ghcr.io/php-cs-fixer/php-cs-fixer:3-php8.3
  52. with:
  53. args: check
  54. # use `check .` if your repository not having paths configured in .php-cs-fixer[.dist].php
  55. Gitlab-CI (Docker)
  56. ~~~~~~~~~~~~~~~~~~
  57. To integrate php-cs-fixer as check into Gitlab-CI, you can use a configuration like this:
  58. .. code-block:: yaml
  59. php-cs-fixer:
  60. image: ghcr.io/php-cs-fixer/php-cs-fixer:${FIXER_VERSION:-3-php8.3}
  61. script:
  62. php-cs-fixer check --format gitlab
  63. # use `check .` if your repository not having paths configured in .php-cs-fixer[.dist].php
  64. Update
  65. ------
  66. Locally
  67. ~~~~~~~
  68. The ``self-update`` command tries to update ``php-cs-fixer`` itself:
  69. .. code-block:: console
  70. php php-cs-fixer.phar self-update
  71. Globally (manual)
  72. ~~~~~~~~~~~~~~~~~
  73. You can update ``php-cs-fixer`` through this command:
  74. .. code-block:: console
  75. sudo php-cs-fixer self-update
  76. Globally (Composer)
  77. ~~~~~~~~~~~~~~~~~~~
  78. You can update ``php-cs-fixer`` through this command:
  79. .. code-block:: console
  80. ./composer.phar global update friendsofphp/php-cs-fixer
  81. Globally (homebrew)
  82. ~~~~~~~~~~~~~~~~~~~
  83. You can update ``php-cs-fixer`` through this command:
  84. .. code-block:: console
  85. brew upgrade php-cs-fixer
  86. Locally (PHIVE)
  87. ~~~~~~~~~~~~~~~
  88. .. code-block:: console
  89. phive update php-cs-fixer
  90. .. _php-cs-fixer.phar: https://cs.symfony.com/download/php-cs-fixer-v3.phar